Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Helge <hl.statlist@googlemail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: estimates save/add problem in regression loop |

Date |
Wed, 1 Sep 2010 15:01:33 +0200 |

dear statalist, i have modified a regression loop i use to generate output to also save all regression results in memory (i used to clear them after each table was generated) so i can have a look at specific e(sample) and other things later if necessary. this is my code ------------------------------------- version 10 set more off cap log close cd $datadir log using regressions_test, replace use regress_final.dta, clear cd results local i1 "Lgdpgr mob_fixed wdi_urbanpop Lopen Ldurable" /*local i2 "mob_fixed wdi_urbanpop Lopen Ldurable yrsforeign yrsanarchy yrstrans"*/ /*local i3 "Lpart Lcomp"*/ local vars "T left_wing right_wing political_ctrl ethn_sep ethn_sep_ctrl muslim religious religious_ctrl guerilla guerilla_ctrl polwing polwing_ctrl small_org large_org small_org5 large_org5" local tframe0 "" local tframe1 "if tframe==1" local tframe2 "if tframe==2" forvalues j=1/1 { forvalues f=0/2 { foreach z in "" "tg_" { foreach t in "_total" "_civ" "_mil" "_dom" "_int" { foreach y in "" "nkill_" { foreach x of local vars { capture: eststo `z'`y'`x'`t'`f'`j', prefix() title(dependent variable: `z'`y'`x'`t', time frame `f', specification `j'): /// xtnbreg `z'`y'`x'`t' Lgdpqt_2 Lgdpqt_3 Lgdpqt_4 Lgdpqt_5 /// lpop yrsconflict past_T_total Lpolcat_2 Lpolcat_3 Lpolcat_4 year_* `i`j'' `tframe`f'', fe irr iter(40) capture qui testparm Lgdpqt_5 Lgdpqt_4, equal estadd r(p), prefix(gdp_5) capture qui testparm Lgdpqt_4 Lgdpqt_3, equal estadd r(p), prefix(gdp_4) capture qui testparm Lgdpqt_3 Lgdpqt_2, equal estadd r(p), prefix(gdp_3) capture qui testparm Lpolcat_4 Lpolcat_3, equal estadd r(p), prefix(pol_4) capture qui testparm Lpolcat_3 Lpolcat_2, equal estadd r(p), prefix(pol_3) } estout `z'`y'*`t'`f'`j' using tf`f'_`z'`y'`j'`t'.tex, style(tex) /// keep(Lgdpqt_2 Lgdpqt_3 Lgdpqt_4 Lgdpqt_5 lpop yrsconflict past_T_total Lpolcat_2 Lpolcat_3 Lpolcat_4 `i`j'') /// order(Lgdpqt_2 Lgdpqt_3 Lgdpqt_4 Lgdpqt_5 lpop yrsconflict past_T_total Lpolcat_2 Lpolcat_3 Lpolcat_4 `i`j'') /// eform cells(b(star fmt(3)) p(par fmt(3))) /// stats(N_g N p aic bic ic converged gdp_3p gdp_4p gdp_5p pol_3p pol_4p, fmt(0 0 3 0 0 0 0 3 3 3 3 3)) /// starlevels(* 0.1 ** 0.05 *** 0.01) varwidth(15) modelwidth(8) prehead(\begin{sidewaystable} /// \caption{Total `z'`y'`t' by specific groups, variables added to baseline: `i`j'', time frame `f'} /// \footnotesize{\begin{tabular}{l*{@M}{r}} \hline) posthead(\hline) prefoot(\hline) /// postfoot(\hline \end{tabular}} \end{sidewaystable}) /// substitute(_ \_) replace } } } } } cd .. ------------------------------------- I have set prefix() so the names of the saved estimates do not break the 32 character limit. i use capture since some models are not computable and not all quintiles are included in all regressions. at some point i get tg_nkill_ethn_sep_int01 not found. if i then write eststo dir to list the saved estimates, i get "_return __000000 already exists". if i delete the "capture:" before eststo and re-run the loop, i get an error message much earlier "_est_nkill_political_ctrl_total01 invalid name". It seems there is a problem with the character limit, although im wondering why then the error doesnt appear earlier even when i use capture. Stata still seems to add the prefix _est to the saved estimates when i add the testresults, although I set prefix() earlier. I used "eststo, add()" in an earlier version and had the same problem. I thought estadd would do the trick, but apparently it doesnt. Is there any way to get rid of the _est? Other ways to solve this would probably be to either disable the 32 character limit or rename my variables. However, i don't know how to do the former, and for obvious reasons im not really keen on doing the latter. I hope my problem is understandable and the code not too badly written, im a student still and have only been using stata for half a year. Also, if anybody has an idea for a better solution to make the loop continue other than capture, id also be grateful. thanks alot, Helge * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**RE: st: Outreg2 - file cannot be openend** - Next by Date:
**RE: st: choosing between two non nested models** - Previous by thread:
**RE: st: Outreg2 - file cannot be openend** - Next by thread:
**st: Hierarchial Poisson Model and Semidefinite Negative Hessian** - Index(es):