0

I am running a gls model with 1 AR term and would like to see what the coefficient is and whether it is significant within the model; however, it is not printed as part of the summary() output. Is there any way to extract it?

data(iris)
gls = nlme::gls(Petal.Width ~ Petal.Length, data=iris, 
      correlation = corARMA(p=1), method= "ML")
summary(gls)
Nad Pat
  • 3,129
  • 3
  • 10
  • 20
Francesca
  • 63
  • 1
  • 7

1 Answers1

3

Are you asking to see Phi and whether the model is significant relative to independent residuals?

library(nlme)
fm <- gls(Petal.Width ~ Petal.Length, data = iris, 
      correlation = corARMA(p=1), method= "ML")

coef(fm$modelStruct$corStruct, unconstrained = FALSE)
##       Phi 
## 0.2824751 

fm2 <-  update(fm, correlation = NULL)
anova(fm, fm2)
##     Model df       AIC       BIC   logLik   Test L.Ratio p-value
## fm      1  4 -53.46889 -41.42635 30.73444                       
## fm2     2  3 -43.59109 -34.55919 24.79555 1 vs 2 11.8778   6e-04

As mentioned in the comments intervals can also be used here. In this example it gives a one-row matrix whose est. column is Phi.

intervals(fm)$corStruct
##         lower      est.     upper
## Phi 0.1160876 0.2824751 0.4334412
## attr(,"label")
## [1] "Correlation structure:"

intervals(fm)$corStruct["Phi", "est."]
## [1] 0.2824751
G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341
  • Yes, thank you. I had not appreciated that Phi represents the AR term. I also found I can extract Phi with 95%CIs using `intervals(fm2)` – Francesca Oct 21 '21 at 08:41