Statalist


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

RE: st: Validity of R Square with -nl- Regressions


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Validity of R Square with -nl- Regressions
Date   Fri, 20 Jun 2008 13:24:23 +0100

Funny. Maarten sees this definition as "obvious", and I do understand
why. 

I was brought up an old-fashioned way with lots of correlation before
regression and still tend to see the definition of R-square as the
square of the correlation between observed and fitted as the "obvious"
one. 

No doubt there are now people who see a definition in terms of
likelihood results as the "obvious" one. 

Nick 
[email protected] 

Maarten buis

--- "Matthias Flueckiger" wrote:
> I'm estimating a function by the -nl- method. The estimates  I get
> for the coefficients seem ok. The same as when I use MATLAB. But
> concerning the R square reported I have my doubts. They are always
> extremly high (>0.99). But when plotting the fitted function against
> the real data, the match does not seem very good (at least not as
> good as the R square suggests). 
>
> My questions are therefore:
> - is the  r square really the appropriate measure for the fit  for 
> -nl- regressions? If yes is there an explanation why it is so high
> (compared when plotting the curves)

The R square reported by -nl- means what it is supposed to mean: the
proportion of variance explained by the model. It is not some kind of
pseudo-rsquare which can have a very different meaning than the `real'
r-square. 

> - how does Stata calculate the r square, and is there a way I can 
> calculate it 'manually'? (Is it the same formula as with linear
> regressions? Probably not...)

Below I show two ways of computing the R-square: the obvious one: 
R-square = moddel sum of squares / total sum of squares, and a method
discussed here: http://www.stata.com/support/faqs/stat/rsquared.html

*---------- begin example ------------
sysuse auto, clear
nl (mpg = {b0} + {b1}/headroom)
di e(mss)/e(tss)
predict yhat if e(sample)
corr yhat mpg if e(sample)
di r(rho)^2
*----------- end example -------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

Hope this helps,
Maarten


-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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