Hello Statalisters, I've been attempting to run margins after a jackknifed Firth logistic regression and have been so far unsuccessful.
I've replicated the issue here with the dataset auto and some arbitrarily created variables.
Doesn't have to be firthlogit to produce the error but clearly there is something that I am missing in the jackknife part of the command - is there any other way to get at margins after jackknifing the model?
Thanks in advance
I've replicated the issue here with the dataset auto and some arbitrarily created variables.
Code:
. use https://www.stata-press.com/data/r17/auto.dta,clear
(1978 automobile data)
. gen outcome=0
. replace outcome=1 if price>6000
(23 real changes made)
. tab outcome
outcome | Freq. Percent Cum.
------------+-----------------------------------
0 | 51 68.92 68.92
1 | 23 31.08 100.00
------------+-----------------------------------
Total | 74 100.00
. *for the sake of argument, pretend make is our cluster
. gen makecluster=1 if _n<=15
(59 missing values generated)
. replace makecluster=3 if _n>15 & _n<=30
(15 real changes made)
. replace makecluster=4 if _n>30 & _n<=45
(15 real changes made)
. replace makecluster=5 if _n>45 & _n<=60
(15 real changes made)
. replace makecluster=6 if _n>60
(14 real changes made)
. tab makecluster,m
makecluster | Freq. Percent Cum.
------------+-----------------------------------
1 | 15 20.27 20.27
3 | 15 20.27 40.54
4 | 15 20.27 60.81
5 | 15 20.27 81.08
6 | 14 18.92 100.00
------------+-----------------------------------
Total | 74 100.00
. logistic outcome i.foreign##c.mpg ,vce(cluster makecluster) coeflegend
Logistic regression Number of obs = 74
Wald chi2(2) = .
Prob > chi2 = .
Log pseudolikelihood = -33.976694 Pseudo R2 = 0.2591
(Std. err. adjusted for 5 clusters in makecluster)
-------------------------------------------------------------------------------
outcome | Coefficient Legend
--------------+----------------------------------------------------------------
foreign |
Foreign | -.9883114 _b[1.foreign]
mpg | -.4038123 _b[mpg]
|
foreign#c.mpg |
Foreign | .1612575 _b[1.foreign#c.mpg]
|
_cons | 6.383446 _b[_cons]
-------------------------------------------------------------------------------
Note: _cons estimates baseline odds.
. jackknife _b[1.foreign] _b[mpg] _b[1.foreign#c.mpg] _b[_cons],eclass cluster(makecluster) mse:firthlogit outcome i.foreign##c.mpg,
(running firthlogit on estimation sample)
Jackknife replications (5): ..... done
Jackknife results Number of obs = 74
Replications = 5
Command: firthlogit outcome i.foreign##c.mpg
_jk_1: _b[1.foreign]
_jk_2: _b[mpg]
_jk_3: _b[1.foreign#c.mpg]
_jk_4: _b[_cons]
n(): e(N)
(Replications based on 5 clusters in makecluster)
------------------------------------------------------------------------------
| Jknife *
| Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
_jk_1 | -1.424797 3.277778 -0.43 0.686 -10.52537 7.675774
_jk_2 | -.3647182 .2051076 -1.78 0.150 -.9341882 .2047518
_jk_3 | .1703893 .2085935 0.82 0.460 -.408759 .7495376
_jk_4 | 5.735816 3.217074 1.78 0.149 -3.196212 14.66784
------------------------------------------------------------------------------
. margins i.foreign,
variable _jk_1 not found
r(111);
Thanks in advance

Comment