ModelEnvMatrix: Generate a model environment from design and response matrix

Description Usage Arguments Details Value Examples

View source: R/Data.R

Description

A simple model environment creator function working off matrices for input and response. This is much simpler and more limited than formula-based environments, but faster and easier to use, if only matrices are allowed as input.

Usage

1
2
ModelEnvMatrix(designMatrix=NULL, responseMatrix=NULL,
               subset = NULL, na.action = NULL, other=list(), ...)

Arguments

designMatrix

design matrix of input

responseMatrix

matrix of responses

subset

an optional vector specifying a subset of observations to be used in the fitting process.

na.action

a function which indicates what should happen when the data contain NA's.

other

an optional named list of additional formulae.

...

currently not used

Details

ModelEnvMatrix returns an object of class ModelEnv-class - a high level object for storing data improving upon the capabilities of simple data matrices.

Funny things may happen if the inpiut and response matrices do not have distinct column names and the data new data are supplied via the get and set slots.

Value

An object of class ModelEnv-class.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
### use Sepal measurements as input and Petal as response
data(iris)
me <- ModelEnvMatrix(iris[,1:2], iris[,3:4])
me

### extract data from the ModelEnv object
dim(me@get("designMatrix"))
summary(me@get("responseMatrix"))

### subsets and missing values
iris[1,1] <- NA
me  <- ModelEnvMatrix(iris[,1:2], iris[,3:4], subset=1:5, na.action=na.omit)

## First case is not complete, so me contains only cases 2:5
me
me@get("designMatrix")
me@get("responseMatrix")

## use different cases
me@set(data=iris[10:20,])
me@get("designMatrix")

## these two should be the same
stopifnot(all.equal(me@get("responseMatrix"), as.matrix(iris[10:20,3:4])))

modeltools documentation built on March 13, 2020, 1:53 a.m.