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
Simulations: Flat log likelihood encountered, cannot find uphill directionDear community, I am trying to see how many times using the Box-Jenkins methodology I select the cor…
Coefficient of VariationDear all Statalist, Just an apparent easy question, even if I am having problems in computation: if…
conditional averagingHello all, this id small part of my data set. in my dataset, there are 18 villages. I want to averag…
Instrumental Variables and using xtivreg with squared termHi - I am using a panel dataset of US companies for the years 2000-19 (US Industrials - Worldscope).…
Is there a way to know the number of unique values under a combination of variables?Dear Statalisters, I have a dataset which tracks individuals who work for different companies at dif…
Subscribe to:
Post Comments (Atom)
0 Response to How to run multiple likelihood-ratio tests using loop function on Stata
Post a Comment