Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: Re: st: Re: st: RE: Ratio of coefficients from two regressions and standard error‏.


From   Steve Samuels <sjsamuels@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: st: Re: st: RE: Ratio of coefficients from two regressions and standard error‏.
Date   Sun, 4 Dec 2011 00:45:18 -0500


Maarten Buis diagnosed this problem at http://www.stata.com/statalist/archive/2007-10/msg00201.html   The second  bootstrap replicate refuses to run because the variable "uhatmain" created by your -predict- statement already exists in the data set; as a result only one replicate is created. Maarten's suggestion: use a temporary variable.  Or,  drop  "uhatmain" at the end of the program.

Also drop all created scalars at the end of the program with a -scalar drop- statement; otherwise those from the last replicate will hang around. 



Steve





On Dec 3, 2011, at 11:20 PM, meenakshi beri wrote:

Hello Steve,

Thanks for your reply and teaching me the way to estimate the ratio and standard error. I am using the same code (after modifying it as per panel data needs and  multiple ratios needs) given by you, but I have been struggling with this insufficient observations error (otherwise my regressions are running fine without bootstrap). I have generated new identifier cluster variable also for the
 bootstrapped panels, as well as generated the new time variable also (whatever information I got using previously existing statalist answers for such a situation, I tried that but nothing worked). Is there something I am doing wrong? 

I get the following error after bootstrap command:

insufficient observations to compute bootstrap standard errors
no results will be saved
r(2000);


Here is my sample code:


program my_xtboot, rclass
xi: xtreg rwhappy hibp diab cancr l_inc_wealth hibp_wealth diab_wealth cancr_wealth  hispanic if sample_black == 1, fe 
scalar define b1 = _b[hibp_wealth]
scalar define b2 = _b[diab_wealth]
scalar define b3 = _b[cancr_wealth]
predict uhatmain, u

xi: xtreg uhatmain l_inc_wealth   hispanic, be  
scalar define b8 = _b[l_inc_wealth]
return scalar ratio1 = b1/b8
return scalar ratio2 = b2/b8
return scalar ratio3 = b3/b8
end

*generating new identiers for bootstrapping

gen long newhhid = .
replace newhhid = hhidpn
     
gen time2 = .
replace time2 = 1 if year == 1992 
replace time2 = 2 if year == 1993 
replace time2 = 3 if year == 1994 
replace time2 = 4 if year == 1995
 
* declaring new panel and time variable
tsset newhhid time2

* getting rid of missing values
generate sample=1-missing(newhhid, time2, l_inc_wealth,  rwhappy, hibp, diab, cancr,  hispanic)
keep if sample

*bootstrap ratio
bootstrap ratio1 =r(ratio1) , reps(100)cluster(hhidpn) idcluster(newhhid) nowarn: my_xtboot if sample_black == 1
estat bootstrap, all

And here is what I get:
   
 bootstrap ratio1 =r(ratio1) , reps(100)cluster(hhidpn) idcluster(newhhid) nowarn: my_xtboot if sample_black == 1
(running my_xtboot on estimation sample)
 :  : 
Bootstrap replications (100)
----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx    50
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx   100
insufficient observations to compute bootstrap standard errors
no results will be saved
r(2000);


Best Regards,
Meenakshi
________________________________
Meenakshi Beri
Graduate Teaching Assistant
Department of Economics
Wayne State University
dy5651@wayne.edu


----------------------------------------
> Subject: st: Re: st: RE: Ratio of coefficients from two regressions and standard error‏.
> From: sjsamuels@gmail.com
> Date: Sat, 3 Dec 2011 16:23:19 -0500
> To: statalist@hsphsun2.harvard.edu
> 
> 
> 
> Bootstrapping the ratio should give good results with fewer assumptions about the regression coefficients.
> 
> Steve
> *************CODE BEGINS*************
> sysuse auto, clear
> capture program drop myboot
> 
> program myboot, rclass
> reg trunk length
> scalar define b1 = _b[length]
> 
> reg weight length
> scalar define b2 = _b[length]
> 
> return scalar ratio = b2/b1
> end
> 
> bootstrap ratio =r(ratio) , reps(40): myboot
> estat bootstrap, all
> **************CODE ENDS**************
> 
> On Dec 2, 2011, at 10:44 AM, meenakshi beri wrote:
> 
> Thanks for your reply. One more question -- how to use Fieller's theorem and derive confidence limits using stata in this case?
> 
> Meenakshi Beri
> Graduate Teaching Assistant
> Department of Economics
> Wayne State University
> dy5651@wayne.edu
> 
> 
> From: Paul.Silcocks@liverpool.ac.uk
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: Ratio of coefficients from two regressions and standard error‏.
> Date: Fri, 2 Dec 2011 09:23:04 +0000
> 
> On the assumption that the two regression coefficient estimates have a Normal distribution, their ratio would have a Cauchy distribution (with no defined variance) if their correlation is zero. If the correlation is non-zero the exact distribution is complicated, though under certain conditions it tends to a Normal distribution.
> 
> You'd be better off instead using Fieller's theorem to obtain confidence limits rather than estimating the standard error
> 
> Paul Silcocks BM BCh, MSc , FRCPath, FFPH, CStat
> Senior statistician,
> Cancer Research UK Liverpool Cancer Trials Unit
> University of Liverpool
> Block C Waterhouse Building
> 1-3 Brownlow Street
> L69 3GL
> 
> email: paul.silcocks@liverpool.ac.uk
> tel: 0151 7948802
> mob: 0794 983 2775
> 
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of meenakshi beri
> Sent: 02 December 2011 06:08
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Ratio of coefficients from two regressions and standard error‏.
> 
> Hello Statalist,
> I am running a fixed effects regression followed by an auxiliary regression to capture the coefficient of time invariant variables. I want to estimate the ratio of two coefficients from these two regressions respectively along with the standard error of the ratio. How can I estimate the ratio and standard error?
> Thanks,Meenakshi BeriWayne State University
> *
> * 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/
> 
> *
> * 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/
		 	   		  
*
*   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   |   Site index