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]
Re: st: How is the R2 for nonlinear least squares obtained?
From
Tirthankar Chakravarty <[email protected]>
To
[email protected]
Subject
Re: st: How is the R2 for nonlinear least squares obtained?
Date
Tue, 5 Jun 2012 13:22:36 -0700
The formula is no different from the linear case - all you need are
the response variable and the model residuals:
************************************************
webuse production, clear
nl (lnoutput = {b0} - 1/{rho=1}*ln({delta=0.5}*capital^(-1*{rho}) ///
+ (1-{delta})*labor^(-1*{rho})))
predict e, resid
mat accum mA = lnoutput e, nocons dev
di "R-squared: " 1-mA[2,2]/mA[1,1]
************************************************
You can work out the algebra for whether the expression you give is
equivalent - my guess is, it is.
T
On Tue, Jun 5, 2012 at 1:08 PM, Zoe Kuehn <[email protected]> wrote:
> Hi
> I am using STATA's nl command for estimating a nonlinear CES function. But
> the R2 that STATA reports does not correspond to the R2 I calculate when
> transferring the data to excel. However, it turns out to be exactly equal
> to a measure called "Cos^2", i.e. the square of the cosine of the angle
> between Y and its predictor (Cos^2=(sum(y*y_hat)^2/(sum(y^2)*sum(y_hat^2)).
> Does somebody know if that is mere coicidence, or if this is the way STATA
> calculates the R2 for Nonlinear least squares? If this is the way STATA
> calculates the R2 for the nl command does anybody know the reason for it?
> Thank you!
> Best
> Zoe
>
> *
> * 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/
--
Tirthankar Chakravarty
[email protected]
[email protected]
*
* 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/