Hi,
I am running an ordered logit model. The outcome variable takes 5 values. When calculating the margins and exporting the results, I get an error that i.agegrp is not found. The codes that I have used:
Example of the data:
I am running an ordered logit model. The outcome variable takes 5 values. When calculating the margins and exporting the results, I get an error that i.agegrp is not found. The codes that I have used:
Code:
global controls heartatk houssiz bmi diabetes i.agegrp black female qui ologit hlthstat $controls [pweight=finalwgt] eststo m1: margins , dydx(*) predict(outcome(1)) qui ologit hlthstat $controls [pweight=finalwgt] eststo m2: margins , dydx(*) predict(outcome(2)) qui ologit hlthstat $controls [pweight=finalwgt] eststo m3: margins , dydx(*) predict(outcome(3)) qui ologit hlthstat $controls [pweight=finalwgt] eststo m4: margins , dydx(*) predict(outcome(4)) qui ologit hlthstat $controls [pweight=finalwgt] eststo m5: margins , dydx(*) predict(outcome(5)) esttab m1 m2 m3 m4 m5 using "omargins.tex", replace b(3) se(3) /// keep($controls) star(* 0.10 ** 0.05 *** 0.01) /// label booktabs noobs nonotes collabels(none) compress alignment(D{.}{.}{-1}) /// mtitle("Excellent" "V.Good" "Good" "Fair" "Poor") nobaselevels stats(N)
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(hlthstat heartatk houssiz) float bmi byte(diabetes agegrp black female) 2 0 4 20.495686 0 4 0 0 2 0 6 21.022337 0 3 0 1 3 0 6 24.97386 0 1 0 1 4 0 9 35.72872 1 5 0 1 2 0 3 27.923803 0 5 0 1 5 0 1 30.502144 0 5 0 1 2 0 2 23.03185 0 5 0 1 1 0 1 23.035156 0 4 0 1 2 0 3 25.63578 0 5 0 1 5 0 4 20.97999 0 5 1 0 2 0 1 31.465527 0 6 0 1 2 0 3 20.184334 0 5 1 1 3 0 4 28.54312 0 2 0 1 4 0 2 20.4144 0 1 0 1 1 0 4 24.9466 0 2 1 0 5 0 1 23.976437 1 5 1 0 5 0 7 38.44014 1 5 0 1 1 0 1 25.925926 0 6 0 1 4 0 1 20.86453 0 6 0 1 3 0 2 18.145163 0 5 0 0 2 0 2 29.09791 0 4 0 1 5 0 3 38.68736 1 4 1 0 1 0 2 21.926546 0 2 0 0 3 0 2 34.226315 0 4 0 1 4 0 2 26.902664 0 5 0 0 1 0 4 23.07461 0 2 0 0 3 0 1 24.33593 0 5 0 1 3 0 2 27.91223 0 4 0 1 3 0 3 26.32063 0 1 1 1 3 0 2 32.59102 0 5 0 0 4 0 2 25.753584 0 5 0 0 1 0 7 30.10884 0 2 1 1 1 0 1 21.084726 0 1 0 1 3 0 3 27.6745 0 5 0 0 4 0 1 22.43288 0 4 0 0 3 0 2 26.54097 0 6 0 1 2 0 4 20.00867 0 1 0 1 2 0 6 25.502905 0 1 1 1 3 0 2 26.94583 0 5 0 1 4 0 2 24.40318 0 5 0 0 2 0 3 24.241745 0 6 0 0 1 0 1 24.19344 0 1 0 0 3 0 8 28.98996 0 1 1 0 4 0 1 21.93411 0 6 0 1 3 0 1 28.57907 0 6 0 1 3 1 2 30.112375 0 5 0 0 3 0 2 20.318064 0 4 0 0 1 0 1 21.385134 0 3 0 0 5 0 2 35.72315 0 5 1 1 3 0 2 21.161545 0 2 0 0 3 0 3 22.207384 0 3 0 1 3 0 4 19.039673 0 2 0 0 1 0 3 26.5538 0 1 0 0 2 0 4 23.75451 0 1 0 0 2 0 3 28.274496 0 5 0 1 1 0 4 22.546875 0 2 0 1 3 0 5 34.772602 0 3 1 0 2 0 2 19.61235 0 5 0 0 2 0 2 30.13859 0 5 1 0 2 0 2 31.379545 0 5 0 1 1 0 1 20.84969 0 1 0 1 3 0 3 21.9425 0 3 0 0 3 0 1 20.241163 0 1 1 0 4 0 8 35.12988 0 4 1 1 3 0 2 28.21959 0 6 0 0 1 0 3 24.421795 0 4 0 0 2 0 4 21.581364 0 1 1 0 4 0 4 37.740726 1 6 0 1 3 0 2 30.77501 0 5 1 0 5 0 5 21.030283 0 6 0 1 4 1 2 25.53069 0 6 0 0 5 0 1 25.24272 0 6 0 0 2 0 2 34.823967 1 5 0 1 4 0 6 33.614716 0 5 1 1 3 0 2 27.63608 0 6 0 0 1 0 3 18.712408 0 1 1 0 3 0 2 23.012417 0 3 0 0 1 0 5 27.02887 0 3 0 0 4 0 2 26.086987 0 5 0 0 1 0 1 30.42313 0 1 0 1 2 1 2 25.67467 0 6 0 1 2 0 2 29.43503 0 5 0 1 2 0 6 25.418964 0 3 0 0 1 0 6 25.101645 0 4 0 1 3 0 4 20.557127 0 3 0 1 4 0 1 26.41101 1 6 1 0 3 0 2 26.817894 0 6 0 1 1 0 1 27.240175 0 3 0 1 4 0 4 36.435555 0 3 0 1 2 0 2 28.42347 0 2 1 1 3 0 3 28.850655 0 4 1 1 1 0 2 37.04592 0 4 0 1 3 1 1 25.452404 0 4 0 1 1 0 2 17.432068 0 6 0 0 3 0 1 31.6263 1 5 1 1 1 0 2 44.01949 0 4 0 1 2 0 2 18.321362 0 5 0 0 1 0 3 21.32432 1 1 0 1 5 0 1 18.99932 0 6 0 1 4 0 4 28.93709 1 5 0 0 end label values hlthstat hlth label def hlth 1 "Excellent", modify label def hlth 2 "Very good", modify label def hlth 3 "Good", modify label def hlth 4 "Fair", modify label def hlth 5 "Poor", modify label values heartatk heartlbl label def heartlbl 0 "No heart attack", modify label def heartlbl 1 "Had heart attack", modify label values diabetes diabetes label def diabetes 0 "Not diabetic", modify label def diabetes 1 "Diabetic", modify label values agegrp agegrp label def agegrp 1 "20–29", modify label def agegrp 2 "30–39", modify label def agegrp 3 "40–49", modify label def agegrp 4 "50–59", modify label def agegrp 5 "60–69", modify label def agegrp 6 "70+", modify label values black black label def black 0 "Not Black", modify label def black 1 "Black", modify label values female female label def female 0 "Male", modify label def female 1 "Female", modify
Comment