recoverdata: Recover data from the data from the model

View source: R/effectsfuns.R

recoverdataR Documentation

Recover data from the data from the model

Description

Recover data from the data from the model

Usage

recoverdata(mod, extras = NULL, envir = environment(formula(mod)), ...)

Arguments

mod

fitted model

envir

data environment

...

for future implementations

optional

character vector or formula specifying the predictors. Important when the transformation are applied in the formula.

Details

It uses the fitted model and the global environment to reconstruct the data used in the model. If data option is specified in the model formula, a dataframe with columns corresponding to the variable in the formula is returned. Any transformation, e.g. log specified in the formula terms is not evaluated on the returned data frame. However, if no is provided, the dataframe is constructed from the formula terms with all transformations evaluated.

Value

a dataframe

Examples

set.seed(4567)
x <- rnorm(100, 3, 5)
y <- 0.4 + 0.7*x + rnorm(100)
df <- data.frame(y = y, x = x)
m1 <- lm(y ~ x, df)
d1 <- recoverdata(m1)
head(d1)
m2 <- lm(y ~ x)
d2 <- recoverdata(m2)
head(d2)


mac-theobio/effects documentation built on July 6, 2023, 4:19 a.m.