Dear all I''m not sure is this question has much sense, but I''m working with nonlinear models using the nlme library (gnls fit for different groups) and I''m wondering if I can get the values of R-squared for each fit. I''ll appreciate any comment. Thanks in advance C. Mora
R^2 = 1 - var(residuals)/var(y) Note, however, that one can get R^2 < 0, e.g., with a straight line through the origin. If "nlme" does not automatically report R^2, this may be why. Hope this helps. Spencer Graves cmorab at bellsouth.net wrote:> Dear all > > I''m not sure is this question has much sense, but I''m working with nonlinear > models using the nlme library (gnls fit for different groups) and I''m > wondering if I can get the values of R-squared for each fit. I''ll appreciate > any comment. > > Thanks in advance > > C. Mora > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Spencer Graves <spencer.graves at pdf.com> writes:> R^2 = 1 - var(residuals)/var(y) > > Note, however, that one can get R^2 < 0, e.g., with a straight line > through the origin. If "nlme" does not automatically report R^2, this > may be why.Neither nls nor the nonlinear model fitting functions from the nlme package report an R^2 value because this statistic doesn''t always make sense for a nonlinear model. R^2 for a linear model is a way of comparing the fitted model to a trivial model that predicts all the responses by a constant. If there is a constant term in the linear model formula (and this can be detected) then the constant model will be nested within the fitted model. For a nonlinear model it would be difficult to determine if the constant model is nested within the fitted model. In many cases it is not and an R^2 value would be very difficult to interpret - some might even say meaningless. If you really want an R^2 value you could use SAS PROC NLIN which *always* produces an ANOVA table and the R^2 value, even when it is meaningless :-).