View source: R/HeightPredict.R
HeightPredict | R Documentation |
This function predicts the heights of any trees that have missing height values. If no height values are provided, heights will be predicted using the FVS acadian growth model (formula citation???). If height values are provided, this function will leverage the provided height, SPP, Stand, and Plot data by running the predicted heights and provided heights through the following equation (HT ~ HTPred + (1|SPP) + (1|Stand/Plot)).
HeightPredict(Stand, Plot, SPP, DBH, CSI, CCF, BAL, HT = NULL)
Stand |
Stand ID for Plot where the nth tree is located. |
Plot |
Plot ID for Plot where the nth tree is located. |
SPP |
Species observation for every tree (FVS species code) |
DBH |
Diameter at breast height in cm. |
CSI |
Climate site index for each tree. |
CCF |
Plot based Crown Competition Factor for each tree. |
BAL |
Basal area of larger trees within the plot |
HT |
Measured HT values for all trees with measured heights (trees with no heights should be entered as 0) |
Stand, Plot, and SPP will only be included as random variables when either at least 5 Unique Stands, Plots and Spp (HT ~ HTPred + (1|SPP) + (1|Stand/Plot)), 5 Unique Plots and Spp (HT ~ HTPred + (1|SPP) + (1|Plot)), or 5 Unique SPP are entered (HT ~ HTPred + (1|SPP)). HTPred is the predicted heights using the acadian growth model formulas. If there are not enough categorical variables for a LMM a simple lm will be run as (HT ~ HTpred) from the acadian growth model.
All measured height values will override predicted values in the output.
Each Plot and Stand needs to have its own unique ID! If plot IDs are recycled they will be lumped together as a single plot in this function.
A simple solution if plot IDs are recycled in each stand (ex Stand 1 Plots 1,2,3,4 - Stand 2 Plots 1,2,3,4) is to create a new variable PlotID. df$PlotID <- paste(Stand, Plot, sep = "-"). This will give you unique plot IDs for every plot. ex: Stand 1 Plots 1_1, 1_2, 1_3, 1_4 - Stand 2 Plots 2_1, 2_2, 2_3, 2_4, etc.
This function requires that all data be entered as a vector of length n. See example.
This function returns a numeric vector of length n with values for all trees with missing heights.
This function returns the random variables used (if any) and a plot of the model's residuals.
Ryan Smith
NEED TO WRITE REFERENCES
BA.Larger.Trees
CCF.Larger
Other Plot Level Functions:
BA.Larger.Trees()
,
BAPH()
,
CCF.Larger()
,
CrownCompF()
,
DBHFuns()
,
RD()
,
SDI.Max()
,
SDI.Plot()
,
TPH()
,
TallestTrees()
,
Unique.ID()
## Not run: ###### RUNNING THE SCRIPT ###### ###### REQUIRES FULL VECTORS ##### ###### AS SEEN HERE ###### trees$HT <- HeightPredict(trees$Stand, trees$Plot, trees$SPP, trees$DBH, trees$CSI, trees$CCF, trees$BAL, trees$HT) ##### RUN WITH FULL VECTORS AND NOT WITH MAPPLY ##### data(tree_data) trees <- tree_data cord <- data.frame(trees$X, trees$Y) sp::coordinates(cord) <- cord sp::proj4string(cord) <- sp::CRS("+proj=longlat +datum=WGS84") CSI <- raster::raster("EastSI_ENSEMBLE_rcp60_2030.tif") CSIdata <- raster::extract(CSI, cord, method = 'simple', df = TRUE) trees$CSI <- CSIdata$EastSI_ENSEMBLE_rcp60_2030 trees <- trees %>% dplyr::mutate( EXPF = EXP.F(DBH, BAF), SDIPlot = SDI.Plot(Stand, Plot, Tree, DBH, EXPF), SDIMax = SDI.Max(Stand, Plot, Tree, SPP, DBH = DBH, EXPF = EXPF, CSI = CSI, X_Coord = X, Y_Coord = Y), BA = BA(DBH), CCF = CrownCompF(Stand, Plot, Tree, SPP, DBH, EXPF), ID = Unique.ID(Stand, Plot), RD = RD(SDIPlot, SDIMax), BAPH = BAPH(Stand, Plot, BA, EXPF), TPH = TPH(Stand, Plot, DBH, EXPF) ) trees <- trees %>% dplyr::group_by(ID) %>% dplyr::arrange(desc(DBH), .by_group = TRUE) trees <- trees %>% dplyr::mutate( BAL = BA.Larger.Trees(ID, DBH, BA) ) trees$HT <- HeightPredict(trees$Stand, trees$Plot, trees$SPP, trees$DBH, trees$CSI, trees$CCF, trees$BAL, trees$HT) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.