[R-sig-eco] Create new corStruct class for lme model

Ben Bolker bbolker at gmail.com
Sat Jan 21 17:40:21 CET 2012


Shawn O'Neil <oneil.shawnt at ...> writes:

> I am running mixed effects models using the nlme package.  I am working
> with a dataset where spatial autocorrelation is inherent in the response
> variable.  I have tested each of the five correlation structures that are
> available for mixed models in nlme, but none of these functions fit my
> spatial correlation pattern very well.  To quote Pinheiro and Bates (2000),
> "New corStruct classes, representing user-defined correlation structures,
> can be added to the set of standard classes and used with the modeling
> functions in the nlme library. For this, one must specify a constructor
> function, generally with the same name as the class, and, at a minimum,
> methods for the functions coef, corMatrix, and initialize."  I am fairly
> new to R and could benefit from an example showing how this is done.  I've
> spent a couple of days searching the net and haven't come up with
> anything.  Can anyone refer me to a good source where a custom corStruct
> class is created and run with gls or lme?

  The best examples I know of are in the ape package, for doing
phylogenetic generalized least-squares problems (PGLS) -- I believe
corBrownian() and corMartins() are in there, there may be others.

  I also started to build some code along these lines for
'antecedent' models, as requested by a poster on the r-sig-mixed-models
list.  I never finished, but what I did get done might be useful:
http://www.math.mcmaster.ca/~bolker/R/misc/newcorstruct.R


http://www.math.mcmaster.ca/~bolker/R/misc/newcorstruct.R



More information about the R-sig-ecology mailing list