add_ID_terms {DImodelsVis} | R Documentation |
Add identity effect groups used in a Diversity-Interactions (DI) model to new data
Description
Utility function that accepts a fitted Diversity-Interactions (DI) model object along with a data frame and adds the appropriate species identity effect groupings to the data for making predictions.
Usage
add_ID_terms(data, model)
Arguments
data |
A data-frame with species proportions that sum to 1 to create the identity effect groupings. |
model |
A Diversity Interactions model object fit using the
|
Value
A data-frame with additional columns appended to the end that contain the grouped species proportions.
Examples
library(DImodels)
data(sim1)
# Fit DI models with different ID effect groupings
mod1 <- DI(y = "response", prop = 3:6,
data = sim1, DImodel = "AV") # No ID grouping
mod2 <- DI(y = "response", prop = 3:6,
data = sim1, DImodel = "AV",
ID = c("ID1", "ID1", "ID2", "ID2"))
mod3 <- DI(y = "response", prop = 3:6,
data = sim1, DImodel = "AV",
ID = c("ID1", "ID1", "ID1", "ID1"))
# Create new data for adding interaction terms
newdata <- sim1[sim1$block == 1, 3:6]
print(head(newdata))
add_ID_terms(data = newdata, model = mod1)
add_ID_terms(data = newdata, model = mod2)
add_ID_terms(data = newdata, model = mod3)
[Package DImodelsVis version 1.0.1 Index]