Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Question about local in post command


From   Thomas de Hoop <t.dehoop@maw.ru.nl>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Question about local in post command
Date   Fri, 08 Aug 2008 11:17:28 +0200

Dear Nick,

Thank you for your answer. Actually in the end I have to say that I agree with you on the stepwise regression. At first I thought stepwise regression would be the best solution. because this imputation of missing data is just a means to an end (with help of the missings . After your answer I started thinking again. I realised that actually the 95% significance level is just a random significance level for the imputation, without any higher meaning. Besides, the ice command takes care of drawing random a value of the posterior distribution of the residual standard error. In the end I have thus decided to follow your advice and abstain from stepwise regression.

Thank you very much for your answer.

Nick Cox schreef:

This raises questions on two levels.
First, in all candour, I don't subscribe at all to what you are doing
with -sw- here. As a good liberal, I don't approve of compulsory reading
except to say that no one should use stepwise without having read Frank
Harrell's book on Regression modelling strategies (Springer, NY, 2001).
However, you don't seek comments on that.
In terms of your code, note that your references to locals like `b_var1'
will all evaluate to empty unless you have defined them earlier. That's
not evident from what you say here.
A more general comment is that understanding what is right and wrong in
this code is difficult because it is not complete. Everything hinges on
_precisely_ what you did earlier and where you did it.
Nick n.j.cox@durham.ac.uk
Thomas de Hoop

I am currently creating several datasets to be used later. I am running 65 stepwise regressions. Each variable is the dependent variable one time. I want to create a dataset wherein the coefficients of each variable are created as variables. Later I want to impute missing values

in my dataset for consumption. For my analysis I only want to use the variables that have a significant effect in the stepwise regression results. Later I will create dummy variables for the variables that have

a significant effect.

With help of these dummy variables I can later impute my missing values with help of the significant variables in the stepwise regression ( if dummy==1). This is not where my question is about but serves as background info.

I have a problem with the post command to create my datasets:

I programmed my do file as follows:

forval i=1/65 {
postfile post`i' `dr`i'' using "C:\Documents and Settings\Thomas\Mijn documenten\Radboud Universiteit Nijmegen\Promotie\Data\Bolgatanga\Statafiles\post`i'", replace

sw, pr(.05): regress var`i' `dr`i''


local local (`b_var1') (`b_var2') (`b_var3') (`b_var4') (`b_var5') (`b_var6') (`b_var7') (`b_var8') (`b_var9') (`b_var10') (`b_var11') (`b_var12') (`b_var13') (`b_var14') (`b_var15') (`b_var16') (`b_var17') (`b_var18') (`b_var19') (`b_var20') (`b_var21') (`b_var22') (`b_var23') (`b_var24') (`b_var25') (`b_var26') (`b_var27') (`b_var28') (`b_var29') (`b_var30') (`b_var31') (`b_var32') (`b_var33') (`b_var34') (`b_var35') (`b_var36') (`b_var37') (`b_var38') (`b_var39') (`b_var40') (`b_var41') (`b_var42') (`b_var43') (`b_var44') (`b_var45') (`b_var46') (`b_var47') (`b_var48') (`b_var49') (`b_var50') (`b_var51') (`b_var52') (`b_var53') (`b_var54') (`b_var55') (`b_var56') (`b_var57') (`b_var58') (`b_var59') (`b_var60') (`b_var61') (`b_var62') (`b_var63') (`b_var64') (`b_var65') foreach j of varlist `dr`i'' {
cap local b_`j'=_b[`j']
if _rc {
local b_`j'=.
}


post post`i' `local'

postclose post`i'
}
}

invalid syntax
post: above message corresponds to expression 1, variable var2


dr`i' are 65 locals consisting of different combinations of var1 till var65 wherein the dependent variable is not in the local. I created the local to create coefficient variables for all 65 regressions. The foreach command serves to create missings for the variables that are not

included as significant variables in the stepwise regression. This command comes from an earlier post in the statalist on http://www.stata.com/statalist/archive/2005-03/msg00009.html.

The mistake is in post post`i' `local'.

It states the following: invalid syntax
post: above message corresponds to expression 1, variable var2

Can somebody please tell me what I did wrong in my commands.



*
* 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/
*
*   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/



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