R 部分比例优势模型中的平均边际效应

R 部分比例优势模型中的平均边际效应,r,R,在部分比例优势模型(PPOM)中,如何获得每个类别/阈值的平均边际效应(AMEs) 这是我在这个论坛上的第一篇帖子。我希望我已经注意到提出好问题的最基本建议 该样本数据集由一个有序结果变量(Y1)和三个自变量(VAR1、VAR2、VAR3)组成 我们得到以下输出,每个类别的系数如下: summary(PPOM) formula: as.factor(Y1) ~ Var1 + Var2 + Var3 nominal: ~Var1 + Var2 + Var3 data: sampleData

在部分比例优势模型(PPOM)中,如何获得每个类别/阈值的平均边际效应(AMEs)

这是我在这个论坛上的第一篇帖子。我希望我已经注意到提出好问题的最基本建议

该样本数据集由一个有序结果变量(Y1)和三个自变量(VAR1、VAR2、VAR3)组成

我们得到以下输出,每个类别的系数如下:

summary(PPOM)

formula: as.factor(Y1) ~ Var1 + Var2 + Var3
nominal: ~Var1 + Var2 + Var3
data:    sampleData

 link  threshold nobs logLik   AIC     niter max.grad cond.H 
 logit flexible  1000 -1381.17 2786.34 4(0)  2.82e-10 2.2e+07

Coefficients: (3 not defined because of singularities)
     Estimate Std. Error z value Pr(>|z|)
Var1       NA         NA      NA       NA
Var2       NA         NA      NA       NA
Var3       NA         NA      NA       NA

Threshold coefficients:
                  Estimate Std. Error z value
1|2.(Intercept)  0.4952642  1.2260010   0.404
2|3.(Intercept)  1.9790234  1.0724982   1.845
3|4.(Intercept)  2.0892425  1.2550636   1.665
1|2.Var1         0.0026194  0.0075920   0.345
2|3.Var1        -0.0077578  0.0065845  -1.178
3|4.Var1        -0.0064243  0.0075364  -0.852
1|2.Var2        -0.0001089  0.0074568  -0.015
2|3.Var2        -0.0082836  0.0063447  -1.306
3|4.Var2        -0.0073638  0.0071008  -1.037
1|2.Var3        -0.0219767  0.0140701  -1.562
2|3.Var3        -0.0157235  0.0121943  -1.289
3|4.Var3        -0.0047098  0.0141844  -0.332
我对每个类别的每个预测值的AMEs感兴趣。通过使用
边距
我只得到所有阈值的AMEs

library(margins) 
summary(margins(PPOM))
输出:

 factor    AME     SE      z      p   lower  upper
   Var1 0.0000 0.0000 1.1365 0.2557 -0.0000 0.0001
   Var2 0.0000 0.0000 1.3056 0.1917 -0.0000 0.0001
   Var3 0.0001 0.0001 0.9990 0.3178 -0.0001 0.0002
有人知道热计算每个类别的艾姆斯吗


任何帮助都将不胜感激

我知道我有点晚了,但我只是写了一个简短(效率相当低)的程序来手动计算这种模型的平均边际效应

部分比例赔率序数logit/probit的平均边际效应的计算方法与正常序数logit/probit的计算方法相同。下面是Cameron和Trivedi的《微观经济计量学:方法和应用》的摘录。屏幕底部的方程式给出了连续变量的边际效应。离散变量的边际效应为Pr(y|i=j | x=1)-Pr(y|i=j | x=0);Pr(y_i=j)在页面顶部的等式中给出

我建议手动计算估计的每组Beta的边际效应。这涉及到保存矩阵/向量,这些矩阵/向量包括您的数据、不同的beta以及您正在计算ME的变量的系数。这也意味着你在为每个结果和每个系数计算不同的ME(在你的例子中,3*有序结果的数量)

下面是我自己编写的一些代码。效率不高,一个接一个地走。它对三种结果计算称为“snap12”的虚拟变量的MEs,这就是为什么有六个方程式。“Cut1”和“Cut2”是截止点(在ME方程中通常称为alpha)。Xdat是数据,不包括我正在计算ME的变量。xcoef1是第一组系数(减去ME变量),xcoef2是第二组系数。Snapcoef1和snapcoef2是ME变量的系数。最后,pnorm给出了顺序probit ME所需的CDF值

我希望这对别人有帮助



##for pr(v low secure)

#1st set of coefficients
p3a = ((1 - pnorm(cut2 - xdat%*%xcoef1 - snapcoef1)) - 
       (1 - pnorm(cut2 - xdat%*%xcoef1)))
#2nd set
p3b = ((1 - pnorm(cut2 - xdat%*%xcoef2 - snapcoef2)) - 
       (1 - pnorm(cut2 - xdat%*%xcoef2)))

#for pr(low sec)
#1st set
p2a = (pnorm(cut2 - xdat%*%xcoef1 - snapcoef1) - pnorm(cut1 - xdat%*%xcoef1 - snapcoef1)) - 
         (pnorm(cut2 - xdat%*%xcoef1) - pnorm(cut1 - xdat%*%xcoef1))

p2b = (pnorm(cut2 - xdat%*%xcoef2 - snapcoef2) - pnorm(cut1 - xdat%*%xcoef2 - snapcoef2)) - 
  (pnorm(cut2 - xdat%*%xcoef2) - pnorm(cut1 - xdat%*%xcoef2))

## for pr(fodo sec)

p1a = (pnorm(cut1 - xdat%*%xcoef1 - snapcoef1)) - (pnorm(cut1 - xdat%*%xcoef1))

p1b = (pnorm(cut1 - xdat%*%xcoef2 - snapcoef2)) - (pnorm(cut1 - xdat%*%xcoef2))



我想你可以用
at
参数来说明这一点吗?看见
 factor    AME     SE      z      p   lower  upper
   Var1 0.0000 0.0000 1.1365 0.2557 -0.0000 0.0001
   Var2 0.0000 0.0000 1.3056 0.1917 -0.0000 0.0001
   Var3 0.0001 0.0001 0.9990 0.3178 -0.0001 0.0002


##for pr(v low secure)

#1st set of coefficients
p3a = ((1 - pnorm(cut2 - xdat%*%xcoef1 - snapcoef1)) - 
       (1 - pnorm(cut2 - xdat%*%xcoef1)))
#2nd set
p3b = ((1 - pnorm(cut2 - xdat%*%xcoef2 - snapcoef2)) - 
       (1 - pnorm(cut2 - xdat%*%xcoef2)))

#for pr(low sec)
#1st set
p2a = (pnorm(cut2 - xdat%*%xcoef1 - snapcoef1) - pnorm(cut1 - xdat%*%xcoef1 - snapcoef1)) - 
         (pnorm(cut2 - xdat%*%xcoef1) - pnorm(cut1 - xdat%*%xcoef1))

p2b = (pnorm(cut2 - xdat%*%xcoef2 - snapcoef2) - pnorm(cut1 - xdat%*%xcoef2 - snapcoef2)) - 
  (pnorm(cut2 - xdat%*%xcoef2) - pnorm(cut1 - xdat%*%xcoef2))

## for pr(fodo sec)

p1a = (pnorm(cut1 - xdat%*%xcoef1 - snapcoef1)) - (pnorm(cut1 - xdat%*%xcoef1))

p1b = (pnorm(cut1 - xdat%*%xcoef2 - snapcoef2)) - (pnorm(cut1 - xdat%*%xcoef2))