Hi everyone,
I am new to Stata. I would really appreciate any help you would provide me.
I ran 209 logistic regressions and stored their estimates (E1, E2, ..., E209).
Of 209 models, the 1st one (M1) is the basic model and rest of 208 models have 208 different additional variables (Mn=m1+Xn, X1=0).
Then, I tried to compare the fitness of every model (M2-M208) to M1 and ran multiple likelihood-ratio tests using loop function, but I could not complete.
Here are the commands I used (I am sorry, but I changed the names of variables and estimates):
// I ran 209 logistic regressions (M1, M2, ..., M209) and stored their estimates (E1, E2, ..., E209)
logit m1+X1
estimate store E1
logit m1+X2
estimate store E2
..........
logit m1+X209
estimate store E209
//stored estimates are _est_E1, _est_E2, ...., _est_E209
//Then, I tried to run multiple likelihood-ratio tests using loop functions
. local var "E1-E209"
. foreach x of local var {
2. lrtest E1 "`x'"
3. }
//Then, I got the following error message:
estimation result E1-E209 not found
I could run lrtest individually, and found that lrtest recognized E1, E2, ..., E209, but local only recognized _est_E1, _est_E2, ..., _est_E209.
How can I run the looped likelihood-ratio test in such a case?
I also would like to get a matrix for p-value of each likelihood test to generate a scattered graph of these p-values.
Thus, tried following commands and partially worked (I could generate the empty matrix)
. unab y:_est_E2-_est_E209
. local l:word count `y'
. matrix p = J(`l',1,.)
. matrix rownames p = `y'
. matrix colnames p = "p"
. matlist p
My question is how I can incorporate these commands into loop commands to run multiple likelihood-ratio tests and generate a matrix for p-value of each likelihood test.
Any help will be greatly appreciated.
Thanks in advance,
Yuki
Related Posts with How to run multiple likelihood-ratio tests using loop function on Stata
Margins postestimation command after xtabond2Hi Statalisters, I ran xtabond2 command to study the dynamic relationship between institutions and …
error term/sigma_e for every/single observation(s)?Dear STATA community, I almost feel a bit ashamed to ask this, but I am very new to STATA and many …
Change yscale on twoway plotHi, I would like to plot the following graph between [2.5 ; 3]: Code: * Example generated by -dat…
Triple Difference vs Difference in Differences?Hi, I'm trying to figure out the right way to implement an estimator. Some notes: I'm using an in…
Convergence not Achieved in Mixed ModelHi, I am trying to fit a crossed-effects mixed model in my data but Stata returns the following err…
Subscribe to:
Post Comments (Atom)
0 Response to How to run multiple likelihood-ratio tests using loop function on Stata
Post a Comment