使用“margins”函数计算边际效应

问题描述

我正在尝试使用 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,...
)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)