0
$\begingroup$

I normally use r.squaredGLMM() (from MuMIn package) to extract marginal and conditional R-squared (or pseudo-R squared) values for my glmm models, however this does not work for nlme models.

For example, I am running this sort of nlme model:

model=nlme(wt~A*(1-exp(k*(t0-age))), #Function
    fixed=A+k+t0~1,#Fixed effects
    random=list(squirrel_id = pdDiag(A+t0+k~1)), #pdDiag specifies random effects are uncorrelated 
    data= growth_envt_F, # Input dataset
    start=c(A=253.6,k=.03348,t0=32.02158), #Specifies where to start 
    na.action=na.omit, #Omit any NA values 
    control=nlmeControl(maxIter=200, pnlsMaxIter=10, msMaxIter=100)) #Maximum number of iterations before determined divergent

Does anyone know a package that I can use to do this given r.squaredGLMM(model) doesn't work with nlme models?

Background: We are working in a situation where we need to compare multiple models to see how the perform relative to each other (without concern for parsimony). We are using these models to estimate growth for real data. The models all appear to do a poor job of estimating growth rate for the data, but this is visually subjective and we have been asked by a reviewer to present a more objective estimate like a goodness of fit measure.

$\endgroup$
14
  • $\begingroup$ Why are you interested in $R^2$ for a nonlinear model? $R^2$ does not have the same interpretation in the nonlinear case as in the linear case. $\endgroup$
    – Dave
    Commented Nov 29, 2021 at 19:08
  • 1
    $\begingroup$ If you haven't considered it already, one alternative I've seen for model comparison in the nonlinear case is mean squared error or root mean squared error. It has the benefit of keeping the statistic in terms of the units of the dependent variable and can be calculated easily with model.rmse = sqrt(mean(model$residuals^2)) $\endgroup$
    – gibson25
    Commented Nov 30, 2021 at 7:25
  • 1
    $\begingroup$ It's generally a hard problem to say what counts as a good fit. Even when $R^2$ has its usual meaning, there are situations where $R^2=0.4$ could be quite good and situations where $R^2 = 0.9$ is not so good. On the other hand, a metric like (R)MSE gives a sense of the variance or the residuals, which gets us to think about the problem in its context, not think about $R^2$ like grades in school where $R^2=0.4$ is like an F that makes us sad and $R^2 = 0.9$ is like an A that makes us happy. // If the reviewers insist on goodness-of-fit metrics, it might to time to have a statistician co-author. $\endgroup$
    – Dave
    Commented Dec 1, 2021 at 15:53
  • 1
    $\begingroup$ RMSE, MSE, and $R^2$ are equivalent from the standpoint of model comparisons (depending on some definitions). The reason people seem to like $R^2$ over (R)MSE is the idea that $R^2$ can be likened to grades in school where $R^=0.4$ is an $F$ and $R^2=0.9$ is an $A$. “I have a grade-$A$ model,” you might say with joy. However, it could be that $0.4$ is very good for one data set while $0.9$ is mediocre for another data set. I am skeptical of drawing an equivalence between $R^2$ and grades. $\endgroup$
    – Dave
    Commented Dec 2, 2021 at 19:51
  • 1
    $\begingroup$ @BlunderingEcologist Yes $\endgroup$
    – Dave
    Commented Dec 2, 2021 at 20:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.