add_interaction_terms {DImodelsVis} | R Documentation |
Utility function that accepts a fitted Diversity-Interactions (DI) model object along with a data frame and adds the necessary interaction structures to the data for making predictions using the model object specified in 'model'.
add_interaction_terms(data, model)
data |
A data-frame with species proportions that sum to 1 to create the appropriate interaction structures. |
model |
A Diversity Interactions model object fit using the
|
The original data-frame with additional columns appended at the end describing the interactions terms present in the model object.
library(DImodels)
data(sim1)
# Fit different DI models
mod1 <- DI(y = "response", prop = 3:6, data = sim1, DImodel = "AV")
mod2 <- DI(y = "response", prop = 3:6, data = sim1, DImodel = "FULL")
mod3 <- DI(y = "response", prop = 3:6, data = sim1, DImodel = "ADD")
mod4 <- DI(y = "response", prop = 3:6, data = sim1,
FG = c("G", "G", "H", "H"), DImodel = "FG")
# Create new data for adding interaction terms
newdata <- sim1[sim1$block == 1, 3:6]
print(head(newdata))
add_interaction_terms(data = newdata, model = mod1)
add_interaction_terms(data = newdata, model = mod2)
add_interaction_terms(data = newdata, model = mod3)
add_interaction_terms(data = newdata, model = mod4)