我正在尝试使用该margins()
函数计算边际效应,但它返回错误:Error in jacobian %*% vcov : non-conformable arguments
. 这是什么问题?如何解决?
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
该文件说它确实支持 multinom() 对象:
## 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,
...
)