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
Z-Transformation for Population DataIn Excel you can do the calculation of the standard deviation in two different ways in order to perf…
Help interpreting the hazard ratio of a variable with positive and negative values in a Cox regression modelHi Statalist. I created a variable that measures 'Age Difference by Gender' within male and female …
Nearest Neighbor MatchingI am using Stata 16 for my analysis. I am trying to obtain treatment effects on the outcome variable…
Difference between margins and predictHi guys, I just noticed something weird and wanted your opinion, I'm probably misunderstanding how …
How to choose between different regression modelsHello, One of the dependent variables for one of my statistical tests, 'distvol' is a variable meas…
Subscribe to:
Post Comments (Atom)
0 Response to How to run multiple likelihood-ratio tests using loop function on Stata
Post a Comment