2

I am trying to calculate marginal effects with the margins() function but it returns an error: Error in jacobian %*% vcov : non-conformable arguments. What is this problem? How to solve that?

    ml <- read.dta("https://stats.idre.ucla.edu/stat/data/hsbdemo.dta")
    ml$prog2 <- relevel(ml$prog, ref = "academic")
    test <- multinom(prog2 ~ ses + write, data = ml) #run the multinomial model
    library(margins)
    margins(test) #when calculating marginal effects, this returns an error:
    Error in jacobian %*% vcov : non-conformable arguments

The document says it does support multinom() objects:

## S3 method for class 'multinom'
margins(
  model,
  data = find_data(model, parent.frame()),
  variables = NULL,
  at = NULL,
  type = NULL,
  vcov = stats::vcov(model),
  vce = c("delta", "simulation", "bootstrap", "none"),
  iterations = 50L,
  unit_ses = FALSE,
  eps = 1e-07,
  ...
)
cliu
  • 933
  • 6
  • 13

0 Answers0