Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

predDF

Create a new data frame for prediction


Description

Build a data.frame for prediction, where one variable varies and all other variables are set to the reference value (median for continuous variables).

Usage

predDF(object, ...)

## S3 method for class 'JointAI'
predDF(object, vars, length = 100L, ...)

## S3 method for class 'formula'
predDF(object, data, vars, length = 100L, ...)

Arguments

object

object inheriting from class 'JointAI'

...

optional specification of the values used for some (or all) of the variables given in vars

vars

name of variable that should be varying

length

number of values used in the sequence when vars is continuous

data

a data.frame containing the original data (more details below)

See Also

Examples

# fit a JointAI model
mod <- lm_imp(y ~ C1 + C2 + M2, data = wideDF, n.iter = 100)

# generate a data frame with varying "C2" and reference values for all other
# variables in the model
newDF <- predDF(mod, vars = ~ C2)

head(newDF)


newDF2 <- predDF(mod, vars = ~ C2 + M2,
                 C2 = seq(-0.5, 0.5, 0.25),
                 M2 = levels(wideDF$M2)[2:3])
newDF2

JointAI

Joint Analysis and Imputation of Incomplete Data

v1.0.2
GPL (>= 2)
Authors
Nicole S. Erler [aut, cre] (<https://orcid.org/0000-0002-9370-6832>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.