effectPlotData: Generate data for plotting or predicting partial effects of...

effectPlotData.regional_mixR Documentation

Generate data for plotting or predicting partial effects of covariates

Description

This function produces a list of data.frames for predicting the partial effect of a focal.predictor current included in a species_mix model.

Usage

## 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, ...)

Arguments

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

Details

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.

Value

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.

Examples


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)


skiptoniam/ecomix documentation built on Sept. 14, 2023, 6:04 a.m.