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]
st: Re: st: Re: st: RE: Ratio of coefficients from two regressions and standard error.
From
Steve Samuels <[email protected]>
To
[email protected]
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
[email protected]
----------------------------------------
> Subject: st: Re: st: RE: Ratio of coefficients from two regressions and standard error.
> From: [email protected]
> Date: Sat, 3 Dec 2011 16:23:19 -0500
> To: [email protected]
>
>
>
> 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
> [email protected]
>
>
> From: [email protected]
> To: [email protected]
> 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: [email protected]
> tel: 0151 7948802
> mob: 0794 983 2775
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of meenakshi beri
> Sent: 02 December 2011 06:08
> To: [email protected]
> 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/