Message: Return type of CI_Session_files_driver::open($save_path, $name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Message: Return type of CI_Session_files_driver::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Message: Return type of CI_Session_files_driver::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Message: Return type of CI_Session_files_driver::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Message: Return type of CI_Session_files_driver::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Message: Return type of CI_Session_files_driver::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Source file: http://ctfs.si.edu/ctfsdev/CTFSRPackageNew/files/tutorials/GrowthChangeGrowth variation through time
Growth changes
GROWTH VARIATION THROUGH TIME
R. CONDIT
Date: July 7, 2012.
The question addressed here is how growth has changed with time, in particular howspecies differ in growth changes. There are two alternative models described:
Growth rate changing linearly with time
Growth rate varying from census to census, but not following a consistent change
Both hypotheses will be tested running models with the R function lmer in the package lme4. You willneed to install the package.
In the CTFSRPackage, there are functions for loading data and calculating growth rates. The functionindividual_grow.table collects results from several other functions to calculate growth rates for individualtrees and assemble them into a table in the format used by lmer. It is described in the Demographypackage.
The purpose is to create tables of growth rates for every tree in every census interval. Choose anydiameter category, and any set of censuses you wish to work with. Here is an example for big trees at BCI(dbh ≥ 400), with all seven censuses included.
The table grate has one row per individual growth measurement, and includes the tree’s tag number,coordinates, species, and dbh at two time periods. The column census gives the census interval, so 1 meansgrowth between census 1 and 2, and 2 means growth from census 2 to 3, etc. The column censusfact is thesame, but as a factor variable instead of an integer. The time column is the mid-point of the intervalover which growth was measured, centered on 1992. This is the format needed by lmer. Thereason for centering time is that it is much better in linear regressions to have the x-axis nearzero.
The argument rnd indicates that dbhs<50 mm are rounded down to 5-mm, necessary because saplingsat BCI in 1982 and 1985 were measuring in 5-mm increments. The growth functions in the CTFS RPackage handle this.
The other columns are
LnSize: log(dbh1)
incgr: growth increment (difference in dbh) per year
LnGrowth: log of the growth rate, with negatives and zeroes converted to 0.1 (from theargument mingrowth in the function)
CRGrowth: power transformation of the growth rate, with negatives maintained negative(exponent = 0.45).
The analyses are most cleanly done using the cube root of growth rate (CRGrowth), so no assumptionsabout negative growths are needed. You are welcome to try either untransformed growth increment (incgr)or the log of growth (LnGrowth).
2. Mean forest-wide growth
First find the mean growth rate of all individuals in each census period using the table grate.
Calculate mean growth increment per census interval, and the mean(incgr) and mean(CRGrowth).These are simply the observed mean growth rates in all 6 census intervals. The time, meanyr, is the meanyears since 1992 of each census interval.
Graph mean growth vs. time. In this example, I use the mean of the cube-root of growth, but cube it toreturn to the original scale. You could also simply graph the mean growth increment.
> expon=0.45 > par(cex=1.5) > plot(I(root^(1/expon))~meanyr,data=meanGrowth,type='l',xlab='years since 1992',ylab='median growth increment',xlim=c(-10,17),ylim=c(0,9))
3. Mixed model to assess species variation in linear changes through time
The function lmer runs a linear regression of growth rate vs. time, with species as a random effect. This isequivalent to a hierarchical model, where a Gaussian distribution describes the variation in speciesresponses. The cube root of growth is used as the response, in order to come closer to a normal error term(required in textitlmer) while not requiring artificial exclusion of negative growth rates (as alog-tranformation would).
Since BCI growth rates declined over the first 3 censuses, but have not changed since, I chose to runseparate models for census ≤ 3 and census ≥ 3. You may want to make a similar division, or run a singlemodel with all censuses at once.
The 1 + time component means to fit a model of CRGrowth against time, with an intercept (the 1). The nextcomponent, (1 + time|species) means that the intercept and slope should both be allowed to vary acrossspecies. Then (1+time|tag) accounts for repeated measures of individuals by using the tree tag (identifyingindividual trees) as a random effect.
The coefficients of each model are the key result. The fixed effect gives the forest-wide response, which isthe average growth of the species. It is thus not the same as the mean forest-wide growth, because thefixed effect weights each species equally.
The following graph uses the function fixef to get the parameters, then the function curve to add themto the graph. The points are forest-wide means, as graphed above.
With lmer, accounting for the repeated measures of individual trees is easy to model. The tree tag,which identifies individuals, is added as a random effect. This is a fully nested model, individualwithin species. Here are the same two models as above, but now with tag added as a randomeffect. The graph overlays fixed effects from both models, with the model including tag ingreen.
3.3. Statistical signficance of the fixed effects.
Use the function display from the arm package to summarize the model results. All four models aredisplayed below.
The first section printed to the screen by display is the fixed effect, including both the coefficients (firstcolumn) and their standard error (second column). The term for time is how growth changed throughtime, negative numbers showing it declined. Confidence limits can be estimated by adding and subtracting2 times the standard error. Display also repeats the model, to help keep track of which iswhich.
Whether or not tag was added to the model, the fixed effect of time shows that the average response wasnegative, and highly significantly so, over the first 3 census intervals. The models for census 3 and beyond,though, inclusion of tag alters the fixed effect: growth rate increased significantly when tag is not in themodel, but adding tag changes the effect to slightly negative, though not significant. The graph aboveshows this; note that the differences are slight.
3.3.1. Model for census intervals 1-3, without tag.
> display(gmod1,digits=5)
lmer(formula = CRGrowth ~ 1 + time + (1 + time | species), data = subset(grate, census <= 3), verbose = TRUE) coef.est coef.se (Intercept) 1.74035 0.07332 time -0.09083 0.00841 Error terms: Groups Name Std.Dev. Corr species (Intercept) 0.59095 time 0.04298 -0.30013 Residual 1.25747 --- number of obs: 3775, groups: species, 108 AIC = 12662.8, DIC = 12628.6 deviance = 12639.7
3.3.2. Model for census intervals 1-3, with tag.
> display(gmod1tag,digits=5)
lmer(formula = CRGrowth ~ 1 + time + (1 + time | species) + (1 + time | tag), data = subset(grate, census <= 3), verbose = TRUE) coef.est coef.se (Intercept) 1.73024 0.07287 time -0.09990 0.00828 Error terms: Groups Name Std.Dev. Corr tag (Intercept) 0.46947 time 0.04907 -1.00000 species (Intercept) 0.58338 time 0.04262 -0.19470 Residual 1.09077 --- number of obs: 3775, groups: tag, 2195; species, 108 AIC = 12555.7, DIC = 12515.4 deviance = 12526.5
3.3.3. Model for census intervals 3-6, without tag.
> display(gmod2,digits=5)
lmer(formula = CRGrowth ~ 1 + time + (1 + time | species), data = subset(grate, census >= 3), verbose = TRUE) coef.est coef.se (Intercept) 1.73344 0.07290 time 0.00424 0.00253 Error terms: Groups Name Std.Dev. Corr species (Intercept) 0.64072 time 0.00535 -0.51690 Residual 1.03625 --- number of obs: 6411, groups: species, 112 AIC = 18910.3, DIC = 18870.9 deviance = 18884.6
3.3.4. Model for census intervals 3-6, with tag.
> display(gmod2tag,digits=5)
lmer(formula = CRGrowth ~ 1 + time + (1 + time | species) + (1 + time | tag), data = subset(grate, census >= 3), verbose = TRUE) coef.est coef.se (Intercept) 1.82540 0.07471 time -0.00481 0.00271 Error terms: Groups Name Std.Dev. Corr tag (Intercept) 0.72387 time 0.02603 -0.53405 species (Intercept) 0.62677 time 0.01046 -0.47723 Residual 0.82199 --- number of obs: 6411, groups: tag, 2514; species, 112 AIC = 18295.7, DIC = 18250.6 deviance = 18264.2
3.4. Individual species variation.
The real strength of lmer comes from the examination of how individual species vary. In the output ofdisplay, there are summary coefficients called Error terms. Each of these is a standard deviation acrossspecies: it measures how different species are.
Consider first the intercept in the first model, with tag included (the model named gmod1tag). The fixedeffect, or average intercept of all species, is 1.38. But species differ, with standard deviation 0.39. Recallthat most results fall within 2 standard deviations of the mean. This means that individual species haveintercepts as high as 2.16 (1.38 + 2 × 0.39), and others as low as 0.60. Recall also that those are cube roots,since the model was run with CRGrowth.
But the main point has been how growth rate varies through time, given as the time parameters. UnderError terms, the species effect for time is 0.026, and the fixed effect −0.0599. This means that the nearlythe entire distribution of species responses falls < 0, meaning nearly all species had declining growth.In the second time interval (after census 3), species level variation was lower by a factor of4.
There are additional Error terms for the tag, and a Residual term. The former shows variation amongindividuals within a species; notice it is approximately as high as the species term. The latter, Residual, isall remaining variation, which means variation in growth rates of individual trees in differentcensus intervals, after accounting for the time effect. It is always higher than either species-levelor individual-level variation, meaning most of the variance in growth is unexplained by themodel.
3.5. Individual species responses.
But lmer returns more: a set of coefficients for every species, and these make for directinterpretation. The function coef, also in the arm package, returns all coefficients. Here is graphoverlaying every individual species onto the graph of fixed effects, using the models with tagincluded. The entire set of species coefficients are returned by coef(gmod1tag)$species; here I savethose into a temporary variable called cf to reduce the amount of typing. There is a loopthrough every species, using the function curve to overlay one species’ results with a gray line.Since I chose to run models for two separate intervals of time, I repeat this for gmod1tag thengmod2tag. At the end, I add the fixed effects again, just as above, plus points for the forest-widemeans.
Visually it is evident first that most of the variation between species is in the intercept term, whileslopes of the lines are fairly consistent.
4. Mixed model to assess species variation and temporal variation
An alternative model of growth change is to consider each census interval as a separate effecton growth, but without a linear change of growth through time. This would be reasonable ifthere is no a priori reason to expect steady increase (or decrease) in growth rate with time.Growth is allowed to vary from one census interval to the next, but can increase then decrease,etc.
The same function, lmer can be used, but now time is not a numeric variable, but simply a factor. Thetable already created, grate, has a column called censusfact, simply a number designating census intervals,but a factor, not an integer. Check this using R’s function str.
The coefficients are returned in the same way as they would be by R’s function lm. The interceptterm is the estimated growth rate (cube root) in whatever census period comes first (in thiscase, censusfact=1). The remaining coefficients show the difference between growth in each ofthe other censuses and the first one. Thus, the intercept has to be added to the remainingcoefficients in order to get the growth rate. The line with cf[,2:6] makes that adjustment, sothat the temporary variable cf has the mean growth rates (root transformed) in each censusperiod.
In the graph in which the x-axis is time, the responses will not be straight lines because the assumptionof linear change has been removed.
Coefficients of every species can be evaluated to examine hypotheses about how growth differed betweencensus intervals. For example, at BCI, the fixed effect of this model shows that the highest average growthwas in the 1st interval, and species were extremely consistent about this: 115 of 117 had their highestgrowth rates in the first interval. The lowest average growth was the 5th interval, but the difference amongintervals 3-6 was small, and species were much less consistent: 77 had their lowest growth rate in the 5thinterval, but 11 did so in the 2nd and 16 others in the 3rd. Ten species’ lowest growth was in the finalinterval.
How many species had their highest growth in the first census interval?
How many species had their lowest growth in the last interval?
Did growth rate in the first interval correlate with growth in the last?
Do saplings respond similarly to big trees (ie, repeat the model for dbh range 10-50 mm, orother sizes)?