Statalist


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

RE: st: Re: computation of R-squared with a non-linear model


From   marcel spijkerman <[email protected]>
To   stata stata <[email protected]>
Subject   RE: st: Re: computation of R-squared with a non-linear model
Date   Fri, 22 May 2009 09:02:49 +0000

 
Instead of a linear regression I use a weighted nl-procedure using transformed (square-roots) variabels. Indeed, both the adjusted and unadjusted R-squared are 1.000. 
Actually, what I finally did was what Paul suggests below. First I use predict after estimating the model, then I transform the predicted values back to their original state and compute correlations between the original dependent and predicted values, weigthed by the same weight I use in the regression. 
 
The adjusted R-squared is not 1.000 but 0.96. Still very high of course but that has to do with the model. However, I followed up Maarten's suggestion to experiment with different starting values. 
No matter what starting values I use, the model converges to the same results. I estimated the same model in E-views and results are exactly the same. So, I don't think there is something wrong with  convergence. Instead, I think that Stata returns 1.000 because of the transformed variabels. The R-square actually is not really 1.000 but something like 0.999999.
 
So, I guess that things are solved now. Thanks to everyone who answered.
 
Marcel
 
 
 

 
 
 
 
> Date: Fri, 22 May 2009 09:25:00 +0100
> From: [email protected]
> To: [email protected]
> Subject: st: Re: computation of R-squared with a non-linear model
> 
> There is a simple way to compute R-squared for any regression model, 
> if you do not believe the value given by Stata: Calculate the predicted 
> values and carry out your own correlation.
> 
> Using the auto data set:
> 
> **** Start Stata code *****
> sysuse auto
> regress weight price
> 
> predict pred_w
> su weight pred_w
> corr weight pred_w
> 
> di "R-squared = " r(rho)*r(rho)
> **** End Stata code *****
> 
> Both ways giver a value of 0.2901023
> In general, the use of weights and adjusted R-squared 
> makes things more complicated, and the last two lines 
> could be changed to allow for them;
> but neither will alter a correltion of 1.0.
> 
> If Marcel Spijkerman uses this approach, he may find 
> a) Marcel is right - the second R-squared is different
> from the first. (He does not say, but I assume that 
> both the adjusted and unadjusted R-squared are 1.0).
> 
> b) Martin Buis is right - the model has failed to converge, 
> and the predicted values are mostly or completely undefined.
> 
> c) Stata is right - both methods give R-squared = 1.0
> 
> d) Something else I haven't though to.
> 
> I'd be interested to know which.
> 
> 
> 
> 
>>> Date: Wed, 20 May 2009 08:27:31 +0000
>>> From: [email protected]
>>> Subject: RE: st: Re: computation of R-squared with a non-linear model
>>> To: [email protected]
>>>
>>>
>>> --- "marcel spijkerman" wrote:
>> 
>>>>>>>>> I estimate a weighted non-linear model of the
>>>>>>>>> following form:
>>>>>>>>>
>>>>>>>>> y0.5 = (a1 + a2*X)0.5 weighted by some other
>>>>>>>>> variable z.
>>>>>>>>>
>>>>>>>>> Stata reports an adjusted R-squared of 1.000. I
>>>>>>>>> suspect this is not correct. How can compute the
>>>>>>>>> correct adjusted R-squared using untransformed
>>>>>>>>> variables?
>>>>> 
>>>
>>> --- Martin Weiss wrote:
>> 
>>>>>>> Which command did you use for your estimation? If it
>>>>>>> was non-linear, -nl-?
>>>>>>> Show us what you typed and what the reply was...
>>>> 
>>>
>>> --- On Wed, 20/5/09, marcel spijkerman wrote:
>> 
>>>>> I indeed typed the command:
>>>>>
>>>>> nl (sqrt_y = (a1 + a2X)0.5) [aweight= hhd1564_06]
>>>>>
>>>>> And the answer is .... :-) 
>>> 
>>>
>>> It is surprising that you got output at all, as you
>>> did not specify any parameters. Anyhow, it appears that
>>> you have a convergence problem. So the next step is
>>> not to try to come up with some correct R2, but to
>>> fix the model. You could try specifing starting
>>> values.
>>>
>>> -- Maarten
>>>
>>> Ps. -aweights- are very very very rarely the correct
>>> weight type.
>>>
> Paul T Seed MSc CStat CSci, Senior Lecturer in Medical Statistics,
> tel (+44) (0) 20 7188 3642, fax (+44) (0) 20 7620 1227
> Wednesdays: (+44) (0) 20 7848 4208 
> 
> 
> 
> *
> * 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/
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index