extract: Convenience function to extract data from a model

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Convenience function to extract data from a model.

Usage

1
2
extract_target(model, dataset)
extract_predictors(model, dataset)

Arguments

model

A function that takes a data frame as its argument and returns an object that has a terms method.

dataset

A data frame.

Details

text

Value

For extract_target, a vector that contains the values from dataset of the dependent variable specified in model. For extract_predictors, the same thing but now the model.matrix of the predictors.

Author(s)

Gray Calhoun <gcalhoun@iastate.edu>

References

Calhoun, G. 2011, Documentation appendix: An asymptotically normal out-of-sample test of equal predictive accuracy for nested models. Unpublished manuscript.

See Also

mixedwindow, clarkwest, terms, model.matrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
model <- function(d) lm(y ~ x, data = d)
dataset <- data.frame(y = rnorm(10), x = rnorm(10))


all.equal(extract_target(model, dataset), dataset$y,
          check.attributes = FALSE)



all.equal(extract_predictors(model, dataset),
          cbind(1, dataset$x), check.attributes = FALSE)

grayclhn/oosanalysis-R-library documentation built on May 17, 2019, 8:33 a.m.