Learn R Programming

pim (version 2.0.2)

model.matrix.pim: Create a model matrix for a probabilistic index model

Description

This function creates a model matrix for use in a probabilistic index model. This model matrix can be passed to pim.fit.

Usage

model.matrix(object, ...)

# S4 method for pim model.matrix(object, data, ...)

# S4 method for pim.formula model.matrix( object, data, model = c("difference", "marginal", "regular", "customized"), ... )

Arguments

object

a pim.formula object that contains the formula necessary for constructing the model matrix.

...

extra arguments passed to or from other methods. This is currently only implemented in concordance with the generic model.matrix function.

data

an optional argument specifying the data frame for which the model matrix should be constructed. See also model.matrix) in the stats package.

model

a single character value with possible values "difference" (the default), "marginal", "regular" or "customized". See also pim.

Value

a design matrix for a pim model

Examples

Run this code
# NOT RUN {
data("FEVData")
# Create the "model frame"
FEVenv <- new.pim.env(FEVData, compare="unique")
# This includes the poset
pos <- poset(FEVenv, as.list=TRUE)

# create the formula and bind it to the pim.environment.
FEVform <- new.pim.formula(
  Age ~ I(L(Height) - R(Height))  ,
  FEVenv
)

# Use this formula object to construct the model matrix
# use the default model ( difference )
MM <- model.matrix(FEVform)

# Use this formula object to construct the pseudo response
Y <- response(FEVform)

# Now pim.fit can do what it does
res <- pim.fit(MM,Y, estim = "estimator.glm", penv=FEVenv)

# }

Run the code above in your browser using DataLab