effectPlotData.regional_mix | R Documentation |
This function produces a list of data.frames for predicting the partial effect of a focal.predictor current included in a species_mix model.
## S3 method for class 'regional_mix'
effectPlotData(focal.predictors, mod, ngrid = 50, ...)
effectPlotData(focal.predictors, mod, ...)
## S3 method for class 'species_mix'
effectPlotData(focal.predictors, mod, ngrid = 50, ...)
focal.predictors |
A character or string of characters which represent covariates in the model. |
mod |
The fitted species_mix model. |
ngrid |
The length of the prediction vector. |
... |
other arguments |
Generate data for plotting or predicting partial effects of covariates
This function produces a list of data.frames for predicting the partial effect of a focal.predictor current included in a species_mix model.
This function should return a list of data.frames one for each focal.predictor. This will enable user to predict marginal effects or plot the partial response plots.
library(ecomix)
set.seed(42)
sam_form <- stats::as.formula(paste0('cbind(',paste(paste0('spp',1:20),
collapse = ','),")~x1+x2"))
sp_form <- ~ 1
beta <- matrix(c(-2.9,-3.6,-0.9,1,.9,1.9),3,2,byrow=TRUE)
dat <- data.frame(y=rep(1,100),x1=stats::runif(100,0,2.5),
x2=stats::rnorm(100,0,2.5))
dat[,-1] <- scale(dat[,-1])
simulated_data <- species_mix.simulate(archetype_formula = sam_form,species_formula = sp_form,
data = dat,beta=beta,family="bernoulli")
fm1 <- species_mix(archetype_formula = sam_form,species_formula = sp_form,
data = simulated_data, family = 'bernoulli', nArchetypes=3)
effectPlotData("x1",fm1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.