INLAstep | R Documentation |
Run forwards or backwards stepwise variable selection with INLA regression. Only fixed effects will be considered for removal. Use holdout data or within sample data to test new models. Choose the level of interactions and power terms to expand the model formula to. Force part of the model to remain in the model (e.g. the spatial term and intercept).
INLAstep( fam1 = "gaussian", dataf, spde = NULL, in_stack = NULL, invariant = "0 + Intercept", direction = c("forwards", "backwards"), y = NULL, y2 = NULL, include = NULL, powerl = 1, inter = 1, thresh = 2, num.threads = 1, ... )
fam1 |
String defining the likelihood familiy. |
dataf |
A dataframe including covariates and response data. |
spde |
An spde model object for the spatial component. |
in_stack |
An inla.data.stack object containing all needed data. |
invariant |
The part of the formula that should not change (e.g. the intercept and the spatial component.) |
direction |
string 'forwards' for forward variable selection and 'backwards' for backwards variable elimination. |
y |
String determining the response variable. |
y2 |
String determining the name of the test response data. |
include |
Vector of integers to determine which columns in dataf should be used. If NULL, use all columns except y and y2. |
powerl |
Integer up to 3 determining which power terms to include. |
inter |
Integer up to 3 determining how many levels of intereactions to include. |
thresh |
Threshold difference in DIC for whether a new model should replace the old model. |
num.threads |
How many threads to use for INLA computation. |
... |
Further arguments to |
## Not run: library(INLA) data(Epil) stack <- INLA::inla.stack(data = list(y = Epil$y), A = list(1), effects = list(data.frame(Intercept = 1, Epil[3:5]))) result <- INLAstep(fam1 = "poisson", Epil, in_stack = stack, invariant = "0 + Intercept", direction = 'backwards', include = 3:5, y = 'y', y2 = 'y', powerl = 1, inter = 1, thresh = 2) autoplot(result$best_model, which = c(1, 5), CI = TRUE) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.