modeltools (version 0.2-23)

ModelEnv-class: Class "ModelEnv"

Description

A class for model environments.

Arguments

Objects from the Class

Objects can be created by calls of the form new("ModelEnv", ...).

Slots

env:

Object of class "environment".

get:

Object of class "function" for extracting objects from environment env.

set:

Object of class "function" for setting object in environment env.

hooks:

A list of hook collections.

Methods

clone

signature(object = "ModelEnv"): copy an object.

dimension

signature(object = "ModelEnv", which = "character"): get the dimension of an object.

empty

signature(object = "ModelEnv"): Return TRUE, if the model environment contains no data.

has

signature(object = "ModelEnv", which = "character"): check if an object which is available in env.

initialize

signature(.Object = "ModelEnv"): setup new objects.

show

signature(object = "ModelEnv"): show object.

subset

signature(x = "ModelEnv"): extract subsets from an object.

na.pass

na.action method for ModelEnv objects.

na.fail

na.action method for ModelEnv objects.

na.omit

na.action method for ModelEnv objects.

Details

Objects of class ModelEnv basically consist of an environment for data storage as well as get and set methods.

na.fail returns FALSE when at least one missing value occurs in object@env. na.pass returns object unchanged and na.omit returns a copy of object with all missing values removed.

Examples

# NOT RUN {
### a new object
me <- new("ModelEnv")

## the new model environment is empty
empty(me)

### define a bivariate response variable
me@set("response", data.frame(y = rnorm(10), x = runif(10)))
me

## now it is no longer empty
empty(me)

### check if a response is available
has(me, "response")

### the dimensions
dimension(me, "response")

### extract the data
me@get("response")

df <- data.frame(x = rnorm(10), y = rnorm(10))

## hook for set method:
mf <- ModelEnvFormula(y ~ x-1, data = df, setHook=list(designMatrix=scale))
mf@get("designMatrix")
mf@set(data=df[1:5,])
mf@get("designMatrix")

### NA handling
df$x[1] <- NA
mf <- ModelEnvFormula(y ~ x, data = df, na.action = na.pass)
mf
na.omit(mf)
# }