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 |
Abekah Nkrumah <[email protected]> |

To |
[email protected] |

Subject |
Re: Re: st: Postlist for bootstrap |

Date |
Tue, 4 Jun 2013 10:41:24 +0100 |

Hello Vincenzo, I also checked ur code because I am running a similar code so i realised that the issue was the same name given to the predicted variable. But of course Nick had given you the answer. Concerning the error message of insufficient observations to compute the standard errors, I also received the same error message in my code and have been trying to sort it out but not successful yet, so I am very much interested in the response to your post: See my code below though a bit longer than yours clear set memory 5000 /* the input data file */ use "/Users/machine/Desktop/Ethiopia-child Decomp.dta" /* the output data file */ postfile stak my ciy m01 b01 ci01 c01 m02 b02 ci02 c02 m03 b03 ci03 /* */ c03 m04 b04 ci04 c04 m05 b05 ci05 c05 /* */ using "/Users/machine/Desktop/Ethiopia-child24 Decomp.dta" , replace capture program drop tbstr program define tbstr /* OLS Regreession for the Determinants of Health */ reg neghaz chld_age2 chld_age3 /* */ chld_age4 chld_age5 female_child1, vce(cluster clusta_numb) /* mean values */ sum neghaz scalar my = r(mean) sum chld_age2 scalar m01=r(mean) sum chld_age3 scalar m02=r(mean) sum chld_age4 scalar m03=r(mean) sum chld_age5 scalar m04=r(mean) sum female_child1 scalar m05=r(mean) tempname my ciy m01 b01 ci01 c01 m02 b02 ci02 c02 m03 b03 ci03 /* */ c03 m04 b04 ci04 c04 m05 b05 /* regression coefficients */ sca b01 = _b[chld_age2] sca b02 = _b[chld_age3] sca b03 = _b[chld_age4] sca b04 = _b[chld_age5] sca b05 = _b[female_child1] tempvar rank wi sumwi wj rk gen n = _N egen rank = rank(wealth_transfmed), unique sort rank gen wi = 1/n gen sumwi = sum(wi) gen wj = sumwi[_n-1] replace wj = 0 if wj == . gen rk = wj + 0.5*wi /* concentration indices */ corr rk neghaz , c sca ciy = 2*r(cov_12)/my corr rk chld_age2 , c sca ci01 = 2*r(cov_12)/m01 corr rk chld_age3 , c sca ci02 = 2*r(cov_12)/m02 corr rk chld_age4 , c sca ci03 = 2*r(cov_12)/m03 corr rk chld_age5 , c sca ci04 = 2*r(cov_12)/m04 corr rk female_child1 , c sca ci05 = 2*r(cov_12)/m05 /* contributions from variables in percentage of predicted CI */ sca c01 = 100*b01*m01*ci01/(my*ciy) sca c02 = 100*b02*m02*ci02/(my*ciy) sca c03 = 100*b03*m03*ci03/(my*ciy) sca c04 = 100*b04*m04*ci04/(my*ciy) sca c05 = 100*b05*m05*ci05/(my*ciy) post stak (my) (ciy) (m01) (b01) (ci01) (c01) (m02) (b02) (ci02) (c02) (m03) (b03) (ci03) /* */ (c03) (m04) (b04) (ci04) (c04) (m05) (b05) (ci05) (c05) end /* Bootstrap procedure activated - with 10 replications only for test purpose. Set it up to 1,000 in final run !! */ bootstrap , reps(10): tbstr postclose stak use "/Users/machine/Desktop/Ethiopia-child24 Decomp.dta" , replace /* Descriptive summary of the quantities calculated */ sum my ciy m01 b01 ci01 c01 m02 b02 ci02 c02 m03 b03 ci03 /* */ c03 m04 b04 ci04 c04 m05 b05 ci05 c05 Thank you very much Regards On Tue, Jun 4, 2013 at 10:15 AM, Vincenzo Carrieri <[email protected]> wrote: > Thanks Nick for your suggestion. > I changed the name of the predicted variable as you suggested. However > I get anyway a new error message. Now the message is: > insufficient observations to compute bootstrap standard errors-no > results will be saved > > Maybe the problem is on the use of postfile. I am new on the use of > postfile, but I follow suggestions contained in stata help. > > Any help is appreciated. > Thanks > V. > > > ----------------------------- > > Date: Mon, 3 Jun 2013 17:11:21 +0100 > From: Nick Cox <[email protected]> > Subject: Re: st: Postlist for bootstrap > We can't see your dataset but in > > regress sesso eta > > - -sesso- must be an existing variable, while in > > predict sesso > > - -sesso- must be a new variable name. That won't work therefore. > > Nick > [email protected] > > > On 3 June 2013 16:26, Vincenzo Carrieri <[email protected]> wrote: >> Dear Statalisters, >> I am trying to implement bootstrap estimations of standard errors for >> concentration indexes but I get an error like: the variable "sesso" >> (name of the first variable that I use in the regression) was not > found. I think that the problem is mostly on the use of postfile but > I cannot find the solution. > > Here an example of what I did using just few variables. > > I first using data: > > use "C:\Users\User\Desktop\TEST.dta", replace > > Then I Declare variable names and filename of dataset where results > will be stored > > postfile test2 my ciy m01 b01 ci01 using > "C:\Users\User\Desktop\TEST.DTA",replace > > Then I launch my programme > > capture program drop index > program define index > regress sesso eta > predict sesso > sum sesso > scalar my = r(mean) > sum eta > scalar m01=r(mean) > > tempname my ciy m01 b01 ci01 > sca b01 = _b[eta] > gen rank=reddito > > I compute concentration indices > corr rank sesso , c > sca ciy = 2*r(cov_12)/my > corr rank eta , c > sca ci01 = 2*r(cov_12)/m01 > > post stak my ciy m01 b01 ci01 > > end > > Up to now everything is ok. > > > Finally I do boostrap: > > bootstrap , reps(10) : index > > Here I get the error message: variable sesso not found an error > occurred when bootstrap executed index > > > My code would continue: > > I close the postfile > > postclose test2 > > use "C:\Users\User\Desktop\test.dta", replace > > sum my ciy m01 b01 ci01 > > > Anyone can help me to understand what is wrong in my bootstrap programming > Any help is appreciated. > Thanks, > > Vincenzo > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ -- ************************************************************* Grace and Peace be Multiplied to you through the knowledge of our Lord and Saviour Jesus Christ ********************************************** Dept. of Public Admin & Health Serv. Mgt University of Ghana Business School P.O. Box LG 78 Legon-Accra Ghana Tel: ++ 233 21 500159 Ext. 6247 ++ 233 21 502258 Ext. 6247 ++ 233 21 502255 Ext. 6247 Cell: ++233 243 198 313 Email: [email protected] [email protected] * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**Re:Re: st: Postlist for bootstrap***From:*Vincenzo Carrieri <[email protected]>

- Prev by Date:
**st: Finding out id in Sequence Analysis matrix** - Next by Date:
**Re: Re: st: Postlist for bootstrap** - Previous by thread:
**Re:Re: st: Postlist for bootstrap** - Next by thread:
**Re: Re: st: Postlist for bootstrap** - Index(es):