augment_inla: Run 'inla' with new data and give list of new predictors'...

Description Usage Arguments Details Value Examples

View source: R/augment_inla.R

Description

Run inla with new data and give list of new predictors' positions.

Usage

1
augment_inla(.result, newdata)

Arguments

.result

inla object.

newdata

Dataframe of new data. The column with the response (outcome, dependent variable) must be filled with NAs.

Details

Run inla with new data to allow the use of summary.linear.predictor, summary.fitted.values, marginals.linear.predictor, etc. Then put it in a list with the positions of the newdata described just below. This function is necessary because INLA always keep the original data, as a result we constantly use the row position of the new data when extracting linear predictors, expected predictors (fitted values), etc. More specifically, this function will

Value

List with the following items

inla

updated inla object.

new_pos

integer() of newdata positions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
the_data <- data.frame(
 x1 = rnorm(20, mean = 1, sd = 0.5),
 x2 = rnorm(20, mean = 2, sd = 1),
 sigma = rexp(20))
the_data$mu <- the_data$x1 + the_data$x2
the_data$y <- rnorm(nrow(the_data), mean = the_data$mu, sd = the_data$sigma)
the_inla <- INLA::inla(formula = y ~ x1 + x2, data = the_data)
# the new data used for fitted/predicted values
the_newdata <- data.frame(
 x1 = modelr::seq_range(the_data$x1, n = 5),
 x2 = modelr::seq_range(the_data$x2, n = 5))
augment_inla(the_inla, newdata = the_newdata)

FrankLef/eflINLA documentation built on Dec. 17, 2021, 8:30 p.m.