# [R-sig-eco] nlme model specification

Kingsford Jones kingsfordjones at gmail.com
Thu May 22 19:35:58 CEST 2008

Hi Matthew,

First a couple questions:

The common growth curve models size over time.  Here you are using
size (diam) as a predictor.  What is your response?  Change in size
within a year?

You mentioned a "diversity of replies" to your question, but at the
time you sent it there appeared to be only one on the list.  Were
there others off list?  If so, you may have already gotten comments
similar to those given below, where I agree with the comments given on

On Thu, May 22, 2008 at 7:23 AM, Landis, R Matthew
<rlandis at middlebury.edu> wrote:
> Dear R-sig-eco:
>
> Many thanks to all of those who took the time to reply to my question.  The diversity of replies has made me go back and try to clarify my question.  Apologies for the length of the e-mail.  Thanks in advance to anyone willing to plow through this and understand it.  If you're ever in Middlebury I'll buy you a beer.
>
> To repeat, I have 300 trees, ranging in size from 10 - 150 cm diameter (big trees).  To simplify my original question, let's say I want to understand the relationship between growth and two variables, diameter (continuous) and vine load (ordinal index from 1-4). I'd also like to know the relative importance of diameter vs. vine load, e.g. by partial R2.  If I had one year of data, this would be a simple regression.

~ For the relative importance question you might want to look at the
relimp function in the relimp package -- it takes objects of class
lme.  Also the hier.part and relaimpo packages may be useful.  However
be aware that the idea of R^2 for a model with random effects is
controversial.  Some of the issues and citations are mentioned in this

>
> However, I have 9 years of annual measurements on the trees.  It's as if I have the above analysis repeated 9 times.

~ So, as was pointed out previously, you don't have independent pieces
of information within trees.  Even after modelling the population
through the fixed effects, errors within trees are more likely to be
similar than those between trees.  Also, another important point that
hasn't been pointed out is that even if you add tree id as a random
grouping factor and therefore model within-tree correlation as
$(\sigma^2_{tree})/(\sigma^2_{tree} + \sigma^2_{error})$, you still
are likely to have a lack of indepence induced by temporal
autocorrelation of observations over the years within each tree.  This
is where the correlation argument to lme comes into play.  Because you
have equally spaced measurements the corAR structure may be
appropriate for within-tree errors.

hope this helps,

Kingsford Jones

> There was no initial treatment, so I view these 9 years as a random sample of the years in the life of the tree, and unlike most examples of repeated measures I have read, the time effect is of no interest whatsoever. That is, I am not interested in viewing xyplot(growth ~ time|id).  I don't expect to see any consistent directional response to time.  In a way, it's as if the 9 years represent blocks, (except that it's the same 300 trees in each block) -- this is why I view the yr as a random effect, and as the grouping variable.
>
> If I were to graph the data, I would use xyplot(growth ~ diameter|yr) to see what I am most interested in.  Grouping by individual doesn't make sense to me here because each individual only represents a very small slice of the full range of measurements - e.g. over the ten years, each tree only grows from 10 cm - 14 cm, so I can't really estimate the growth vs. diameter relationship for each tree.  xyplot(growth ~ diameter|id) would not be useful. This is why I don't consider the individual to be the grouping variable, but perhaps I am wrong on this.
>
> So, now, as before, I am back to
>
> fit <- lme(fixed = growth ~ diameter * vines, random = ~ 1|year)
>
> I'm expecting that this will estimate separate intercepts for each year.  Which is what I want (I would like to fit separate slopes by year too, but that model didn't converge).
>
> I guess what I'm most concerned about is whether the significance tests obtained for each term use the appropriate error term and the appropriate degrees of freedom.  I'm currently using something like the following command to test the effect of diameter
>
> anova(fit.full.model, update(fit.full.model, . ~ vines))
>
> But maybe I'm way off base there.
>
> Thanks very much!
>
> Matt Landis
>
>>-----Original Message-----
>>From: r-sig-ecology-bounces at r-project.org
>>[mailto:r-sig-ecology-bounces at r-project.org] On Behalf Of
>>Landis, R Matthew
>>Sent: Wednesday, May 21, 2008 1:55 PM
>>To: 'r-sig-ecology at r-project.org'
>>Subject: [R-sig-eco] nlme model specification
>>
>>Greetings R-eco folks,
>>
>>I'm trying to analyze a dataset on tree growth rates to see
>>which factors are important (and their relative importance
>>too, if I can get that), and I'm having some trouble figuring
>>out how to specify the model, despite having carefully read
>>Pinheiro and Bates, the help files for nlme, Crawley's book on
>>Statistics with S, MASS, and other books besides.
>>
>>The dataset consists of ~ 300 trees measured annually for 10
>>years.  So, I have 9 pseudo-replicated intervals over which to
>>assess growth (about 2700 rows in the dataset).  There are 5
>>different explanatory factors, which are a combination of
>>continuous variables and categorical factors.  Some of these
>>vary with time.  In the end, I would like to get both
>>coefficient estimates and partial R2 (or some other way of
>>ranking them) for each factor.  Unlike most time-series
>>examples in the books, I am not interested in how growth
>>varies with time, nor am I particular interested in
>>interactions of explanatory factors with time.
>>
>>Based on this, I've convinced myself that I should specify the
>>model as:
>>
>>fit <- lme(fixed = growth ~ (x1 + x2 + x3+ x4 + x5)^2, random
>>= ~1|year, method = 'ML')
>>
>>Year is clearly a random effect, and is the grouping variable
>>for the analysis.  Each of the other coefficients is "inner"
>>to this variable.  I'm ignoring individual tree as a grouping
>>factor, since I don't want to estimate separate coefficients
>>for each tree.  Does this sound like the correct way to do this?
>>
>>Thanks for any help.  Apologies if this is more of a
>>statistics question and less of an R question.
>>
>>Matt Landis
>>
>>****************************************************
>>R. Matthew Landis, Ph.D.
>>Dept. Biology
>>Middlebury College
>>Middlebury, VT 05753
>>
>>tel.: 802.443.3484
>>**************************************************
>>
>>
>>        [[alternative HTML version deleted]]
>>
>>_______________________________________________
>>R-sig-ecology mailing list
>>R-sig-ecology at r-project.org
>>https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>>
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>