Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Problems with program


From   "Andrea Molinari" <[email protected]>
To   <[email protected]>
Subject   Re: st: Problems with program
Date   Thu, 18 Aug 2005 15:45:50 +0100

Christian,
Thanks for the suggestion. I tried changing the name of the global, but
still got the same error.
Any more ideas/suggestions are more than welcomed!!!
Thanks
Andrea

----- Original Message ----- 
From: "Christian Holz" <[email protected]>
To: <[email protected]>
Sent: Thursday, August 18, 2005 1:37 PM
Subject: Re: st: Problems with program


> Andrea,
> use another name for your macro "varlist". The ado -outreg- uses
> "varlist" as well. And since you defined it as a global macro (which
> remains valid even in the outreg ado) it most likely interferes here.
> Best from Scotland,
> Christian
> ---
> Christian Holz
> Department of Sociology
> University of Glasgow
> Scotland, U.K.
>
> Andrea Molinari wrote:
> > Richard,
> > Many thanks for your suggestion. I tried using globals, but again it
didn't
> > seem to work. I'm attaching part of the code I'm using (it'll hopefully
be
> > 'readable'). The strange thing is that I'm just having problems with the
> > outreg line of the program (STATA doesn't recognise the loop `var' in
the
> > name of the out file...).
> > Thanks again for help and ideas!
> > Andrea
> >
> > global varlist "text wood paper chem nonmet bamet metal"
> >
> >
> > global xvar "adj ldist eec9mxc ibemxc eftmxc grceec9mc grceec9xc
ibeeec9mc
> > ibeeec9xc ibegrcmc ibegrcxc efteec9mc efteec9xc eftgrcmc eftgrcxc
eftibemc
> > eftibexc eec9nmmc eec9nmxc grcnmmc grcnmxc ibenmmc ibenmxc eftnmmc
eftnmxc
> > lingtie"
> >
> >
> >
> > global xvarsetPRE "adjsePRE ldistsePRE eec9sePRE ibesePRE eftsePRE
> > grceec9msePRE grceec9xsePRE ibeeec9msePRE ibeeec9xsePRE ibegrcmsePRE
> > ibegrcxsePRE efteec9msePRE efteec9xsePRE eftgrcmsePRE eftgrcxsePRE
> > eftibemsePRE eftibexsePRE eec9nmmsePRE eec9nmxsePRE grcnmmsePRE
grcnmxsePRE
> > ibenmmsePRE ibenmxsePRE eftnmmsePRE eftnmxsePRE lingtiesePRE"
> >
> >
> >
> > global xvarsetPOS "adjsePOS ldistsePOS eec9sePOS ibesePOS eftsePOS
> > grceec9msePOS grceec9xsePOS ibeeec9msePOS ibeeec9xsePOS ibegrcmsePOS
> > ibegrcxsePOS efteec9msePOS efteec9xsePOS eftgrcmsePOS eftgrcxsePOS
> > eftibemsePOS eftibexsePOS eec9nmmsePOS eec9nmxsePOS grcnmmsePOS
grcnmxsePOS
> > ibenmmsePOS ibenmxsePOS eftnmmsePOS eftnmxsePOS lingtiesePOS"
> >
> >
> >
> >
> >
> > capture program drop regse
> >
> > program regse
> >
> > local dep `1'
> >
> > local xvar "`2'"
> >
> > local cons `3'
> >
> > regress `dep' `xvar' `cons', robust nocons
> >
> > predict resid, r
> >
> > log on
> >
> > sktest resid
> >
> > jb1 resid
> >
> > log off
> >
> > drop resid
> >
> > *need to re-estimate the R-squared here!
> >
> > capture drop yhat
> >
> > capture drop r2
> >
> > capture drop constant
> >
> > gen constant=1
> >
> > mkmat $xvar constant, mat(xvar)
> >
> > matrix b = e(b)'
> >
> > matrix yhat = xvar * b
> >
> > svmat yhat, name(yhat)
> >
> > quietly corr `dep' yhat
> >
> > gen r2 = r(rho)^2
> >
> > di ":::::::::: R-squared using method 2 :::::::::::"
> >
> > di "R2 =  " r2
> >
> > outreg using PREPOS`var'ss, bdec(3) coefastr se 3aster nor2
> > addstat("R2",r2,"Normality",$jb) adec(4,2) append
> >
> > end
> >
> >
> >
> > foreach var of global varlist {
> >
> >
> >
> > log using chow2stage`var'ss.log, replace
> >
> >
> >
> > log off
> >
> >
> >
> > xtreg srem`var' srep`var' srec`var' lrgdp95pcm lrgdp95pcx lbrer dbt`var'
> > d79-d87 if year<1988, fe
> >
> > outreg using PREPOS`var'ss, bdec(3) coefastr se 3aster nor2 replace
> >
> >
> >
> > xtreg srem`var' srep`var' srec`var' lrgdp95pcm lrgdp95pcx lbrer dbt`var'
> > d93-d99 if year>=1992, fe
> >
> > outreg using PREPOS`var'ss, bdec(3) coefastr se 3aster nor2 append
> >
> >
> >
> > bysort mx: egen msrem`var'PRE=mean(srem`var') if year<1988
> >
> > by mx: egen msrep`var'PRE=mean(srep`var') if year<1988
> >
> > by mx: egen msrec`var'PRE=mean(srec`var') if year<1988
> >
> > by mx: egen mdbt`var'PRE=mean(dbt`var') if year<1988
> >
> > by mx: egen msrem`var'=mean(srem`var') if year>=1992
> >
> > by mx: egen msrem`var'POS=max(msrem`var')
> >
> > by mx: egen msrep`var'=mean(srep`var') if year>=1992
> >
> > by mx: egen msrep`var'POS=max(msrep`var')
> >
> > by mx: egen msrec`var'=mean(srec`var') if year>=1992
> >
> > by mx: egen msrec`var'POS=max(msrec`var')
> >
> > by mx: egen mdbt`var'=mean(dbt`var') if year>=1992
> >
> > by mx: egen mdbt`var'POS=max(mdbt`var')
> >
> >
> >
> >
> >
> > regse uset`var'PRE "$xvarsetPRE" conssePRE
> >
> > matrix rssPREset=e(rss)
> >
> > matrix nPREset=e(N)
> >
> >
> >
> > regse uset`var'POS "$xvarsetPOS" conssePOS
> >
> > matrix rssPOSset=e(rss)
> >
> > matrix nPOSset=e(N)
> >
> >
> >
> > save chowfetse`var'ss, replace
> >
> >
> >
> > log close
> >
> > }
> >
> >
> >
> >
> >
> > ----- Original Message ----- 
> > From: "Richard Williams" <[email protected]>
> > To: <[email protected]>
> > Sent: Wednesday, August 17, 2005 3:45 PM
> > Subject: Re: st: Problems with program
> >
> >
> >
> >>At 03:39 PM 8/17/2005 +0100, Andrea Molinari wrote:
> >>
> >>>Dear all,
> >>>
> >>>I am trying to build a program to estimate the same procedure but with
> >>>seven (slightly) different sets of data. For this, I'm using the
> >
> > forvalues
> >
> >>>loop with seven locals, but this stops if there is a program (which
also
> >>>uses those seven sets of data) inside the loop.
> >>>
> >>>I tried putting the programs outside the loop, and 'call' it inside the
> >>>loop, but in that case the program does not recognise the locals of the
> >>>loop.
> >>>
> >>>Does anyone have any suggestions for solving this problem?
> >>
> >>It would help to see some of your code, but one possibility might be to
> >
> > use
> >
> >>global variables instead of local variables.
> >>
> >>-------------------------------------------
> >>Richard Williams, Notre Dame Dept of Sociology
> >>OFFICE: (574)631-6668, (574)631-6463
> >>FAX:    (574)288-4373
> >>HOME:   (574)289-5227
> >>EMAIL:  [email protected]
> >>WWW (personal):    http://www.nd.edu/~rwilliam
> >>WWW (department):    http://www.nd.edu/~soc
> >>
> >>*
> >>*   For searches and help try:
> >>*   http://www.stata.com/support/faqs/res/findit.html
> >>*   http://www.stata.com/support/statalist/faq
> >>*   http://www.ats.ucla.edu/stat/stata/
> >>
> >
> >
> > *
> > *   For searches and help try:
> > *   http://www.stata.com/support/faqs/res/findit.html
> > *   http://www.stata.com/support/statalist/faq
> > *   http://www.ats.ucla.edu/stat/stata/
> >
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index