# Re: st: Validity of R Square with -nl- Regressions

 From Maarten buis To statalist@hsphsun2.harvard.edu Subject Re: st: Validity of R Square with -nl- Regressions Date Fri, 20 Jun 2008 10:04:46 +0100 (BST)

```--- "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

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/
```