Question

I'm trying to extract a parameter from a model fit by ML which has a correlation structure obtained from corPagel (defined in package ape). The parameter of interest is within the element named apVar in the summary.

library(ape); library(nlme)
cor_lambdaML <- corPagel( 1, avestree, fixed=FALSE )
m <- gls(AUTUMN ~ GREGARIOUSNESS + SEASON + TARSUS + MATURATION + SPRING + MIGRATION + DICHROMATISM + HABITAT + POSTJUVENILE + CONSPICUOUSNESS, correlation = cor_lambdaML, data = avesdata, method = 'ML' )
names(m)
m$apVar

This code produces the following output (please, download a dput with model m here):

           corStruct     lSigma
corStruct 0.03848807 0.03090663
lSigma    0.03090663 0.04403168
attr(,"Pars")
  corStruct      lSigma 
0.858126838 0.008131981 
attr(,"natural")
[1] TRUE

Extracting values of the first matrix is trivial, but how can I extract the value of corStruct within the element attr(, "Pars")?

No correct solution

OTHER TIPS

Not sure how far you need to dig, but m$Pars$corStruct is where the data are stored. Which is to say: m is a list with many components, one of which is Pars . That itself is a list, with a component corStruct .

?glsObject will start you on the path to details of all the list elements.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top