How to calculate pseudo R-square from model equipped with gls from nlme package in R

I used gls from nlme for this model:

require(nlme)

set.seed(101)
mp <-data.frame(year=1990:2010)
N <- nrow(mp)

mp <- within(mp,
     {
         wav <- rnorm(N)*cos(2*pi*year)+rnorm(N)*sin(2*pi*year)+5
         wow <- rnorm(N)*wav+rnorm(N)*wav^3
     })

m01 <- gls(wow~poly(wav,3), data=mp, correlation = corARMA(p=1))

      

I would like to calculate any measure of fitness like a pseudo R-square: which one would you recommend? and how to calculate it?

thank

+3


source to share


3 answers


There are some pseudo R-squares here

R2 <- cor(mp$wow,predict(m01))^2

R2

R2.1 <- 1 - with(mp, (sum((wow-predict(m01))^2)/sum((wow-mean(wow))^2)))

R2.1

      

McFadden pseudo R2



m00 <- gls(wow~1, data=mp, correlation = corARMA(p=1))

R2.n <- 1-(as.numeric(logLik(m01)/logLik(m00)))

R2.n

      

but I do not know which one is better to challenge the kindness appropriate for this model.

+3


source


For comparison, you need some kind of baseline:

> summary(m01)
Generalized least squares fit by REML
  Model: wow ~ poly(wav, 3) 
  Data: mp 
       AIC      BIC    logLik
  226.5434 231.5427 -107.2717

 m01 <- gls(wow~1, data=mp, correlation = corARMA(p=1))
> summary(m01)
Generalized least squares fit by REML
  Model: wow ~ 1 
  Data: mp 
       AIC     BIC    logLik
  256.5048 259.492 -125.2524

      



The problem with non-linear additives is that the mean is no longer the "baseline" and this involves taking the R-squared measure.

+2


source


summary(m01)

should give you what you are looking for if I understand your question correctly? ??fit

will provide you with additional suggestions.

0


source







All Articles