ImputeHeights {lmfor} | R Documentation |
Impute missing tree heights into a forest data using a nonlinear (mixed-effects) model.
Description
A function to impute tree heights in a forest inventory situation where all trees have been measured for diameter but only some trees have been measured for height.
Usage
ImputeHeights(d, h, plot, modelName = "naslund", nranp = 2, varf = TRUE,
addResidual = FALSE, makeplot=TRUE, level = 1,
start=NA, bh=1.3, control=list(),random=NA)
Arguments
d |
A numerical vector of tree diameters, usually given in cm. |
h |
A numerical vector of tree heights, usually given in meters. Should be of the same length as |
plot |
A vector of type |
modelName |
Either (i) a character vector specifying the name of the nonlinear function or (ii) the formula specifying
a linear model.
In case (i) the name should be one of the functions documented on the help page of |
nranp |
Parameters nranp and random specify two alternative ways to specify the random effects of the model. An easy but restricted way
is to use argument
In the case of linear model, the constant (if exists) it always counted as the first term. As an alternative to nranp, argument |
varf |
Numeric with values 0, 1 or 2. If 0 or FALSE, no variance function is used. If varf=1, 2 or TRUE, then the power- type variance function var(e)=sigma^2*w^(2*delta) is used. where weight w is the raw diameter (when varf=1 or TRUE), or w=max(1,dsd+3) (when varf=2), where dsd=(d-D)/SDD. Here d is tree diameter, D and SDD are the mean and standard deviation of diameters on the plot in question. |
addResidual |
Boolean. If |
makeplot |
Should a residual plot of the fitted model be produced for evaluation of goodness of fit?
The plot is produced using the default arguments of function |
level |
The level of prediction. 0 means fixed-effect prediction and 1 means plot-level prediction using the random effects. Has no effect if |
start , bh , control , random |
Arguments passed to |
Details
The function predicts the missing heights using a nonlinear mixed-effects model or a nonlinear fixed-effects model. In mixed-effects model, plot-specific random effects can be used if other tree heights have been measured from the same plot. Also random, normally distributed residual can be added to the heights according to the estimated constant or heteroscedastic residual variance structure.
Value
A list of components
h |
A vector of tree heights, including the measured heights for the trees with known height and imputed heights for the others. |
imputed |
A booelan vector of the same length as h, having value TRUE for imputed heights. Produced as |
model |
The fitted model that was used in imputation. Fitted using |
predType |
A vector of the same length as h, including information on the level of prediction. Value 0 means a measured height (no model prediction is used), value 1 means the plot-level prediction has been done using the estimated plot effects. Value 2 means that no sample trees were available and the prediction is based on fixed part only (if level=0) or on a simulated plot effect (if level=1). |
hpred |
Predicted heights for all trees. Equals to vector h for trees that had missing heights. |
Note
Works only with the nonlinear functions specified in HDmodels
; does not work if the modelName is specified as a linear expression.
Author(s)
Lauri Mehtatalo <lauri.mehtatalo@uef.fi>
References
Mehtatalo, L., Gregoire, T.G., and de Miguel, S. Modeling Height-diameter curves for height prediction. Canadian Journal of Forest Research, 45(7): 826-837, doi:10.1139/cjfr-2015-0054
See Also
fithd
for model fitting and plot.hdmod
for plotting.
Examples
data(spati)
ImpFixed<-ImputeHeights(spati$d,spati$h,spati$plot,level=0)
ImpRandom<-ImputeHeights(spati$d,spati$h,spati$plot,level=1,makeplot=FALSE)
# Try also
# ImpRanRes<-ImputeHeights(spati$d,spati$h,spati$plot,level=1,addResidual=TRUE,makeplot=FALSE)
plot(spati$d[!is.na(spati$h)],
spati$h[!is.na(spati$h)],
col=spati$plot[!is.na(spati$h)],
main="Observations", xlab="d, cm", ylab="h, m",
ylim=c(0,30))
plot(spati$d[ImpFixed$imputed],
ImpFixed$h[ImpFixed$imputed],
col=spati$plot[ImpFixed$imputed],
main="Imputed, Naslund, Fixed", xlab="d, cm", ylab="h, m",
ylim=c(0,30))
plot(spati$d[ImpRandom$imputed],
ImpRandom$h[ImpRandom$imputed],
col=spati$plot[ImpRandom$imputed],
main="Imputed, Naslund, Fixed + Plot", xlab="d, cm", ylab="h, m",
ylim=c(0,30))
# Try also
# plot(spati$d[ImpRanRes$imputed],
# ImpRanRes$h[ImpRanRes$imputed],
# col=spati$plot[ImpRanRes$imputed],
# main="Imputed, Naslund, Fixed + Plot + Tree", xlab="d, cm", ylab="h, m",
# ylim=c(0,30))