I need to run a regression that produces outputs for specific ages (0 to 105) in my dataset, but does so in a way that includes ages +/-3 for each age to give a degree of smoothing.
My current code is:
The produces the desired results (it's the coefficient and se on fyear I'm interested in) but in a fairly badly formatted text file that has "actrate,,," between each regression and doesn't include the labels for act_num. E.g.
Can anyone advise if is possible to
(a) replace the inner loop over ages with a single regression; and/or
(b) not include the "actrate,,," but include the value label for act_num in the output and/or
(c) more generally suggest better way to run this?
Many thanks
My current code is:
Code:
forvalues v=1/22 { forvalues x=0/105 { capture qui poisson actrate postpandemic i.sex#(i.age c.fyear) if age>=`x'-3 & age<=`x'+3 & act_num==`v' [pw=round(population/(abs(`x'-age)+1))], base iter(50) capture qui estout using "H:\myfolder\myoutput.txt" ,append del(",") cells("b se") keep(*.sex#c.fyear) labcol2("`v'|`x'" "`v'|`x'") collabels(none) mlabels(none) } }
Code:
actrate,,, 1.sex#c.fyear,1|0,0,. 2.sex#c.fyear,1|0,.0003093,.0035586 actrate,,, 1.sex#c.fyear,1|1,0,. 2.sex#c.fyear,1|1,.0010353,.0039513 actrate,,, 1.sex#c.fyear,1|2,0,. 2.sex#c.fyear,1|2,.0018247,.0036703 etc
(a) replace the inner loop over ages with a single regression; and/or
(b) not include the "actrate,,," but include the value label for act_num in the output and/or
(c) more generally suggest better way to run this?
Many thanks
Comment