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

Description Usage Arguments Value Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
model.matrix(object, ...)

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

## S4 method for signature '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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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)

pim documentation built on March 26, 2020, 7:57 p.m.