add_interaction_terms {DImodelsVis} | R Documentation |
Add interaction terms 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 necessary interaction structures to the data for making predictions using the model object specified in 'model'.
Usage
add_interaction_terms(data, model)
Arguments
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
|
Value
The original data-frame with additional columns appended at the end describing the interactions terms present in the model object.
Examples
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)
[Package DImodelsVis version 1.0.1 Index]