Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

model.frame.dfidx

model.frame/matrix for dfidx objects


Description

Specific model.frame/matrix are provided for dfidx objects. This leads to an unusual order of arguments compared to the usage. Actually, the first two arguments of the model.frame method are a dfidx and a formula and the only main argument of the model.matrix is a dfidx which should be the result of a call to the model.frame method, i.e. it should have a term attribute.

Usage

## S3 method for class 'dfidx'
model.frame(
  formula,
  data = NULL,
  ...,
  lhs = NULL,
  rhs = NULL,
  dot = "previous",
  alt.subset = NULL,
  reflevel = NULL,
  balanced = FALSE
)

## S3 method for class 'dfidx'
model.matrix(object, ..., lhs = NULL, rhs = 1, dot = "separate")

Arguments

formula

a dfidx

data

a formula

..., lhs, rhs, dot

see the Formula method

alt.subset

a subset of levels for the second index

reflevel

a user-defined first level for the second index

balanced

a boolean indicating if the resulting data.frame has to be balanced or not

object

a dfidx object

Value

a dfidx object for the model.frame method and a matrix for the model.matrix method.

Author(s)

Yves Croissant

Examples

data("TravelMode", package = "AER")
TM <- dfidx(TravelMode)
mf <- model.frame(TM, choice ~ vcost | income - 1 | travel)
head(model.matrix(mf, rhs = 1))
head(model.matrix(mf, rhs = 2))
head(model.matrix(mf, rhs = 1:3))

dfidx

Indexed Data Frames

v0.0-4
GPL (>= 2)
Authors
Yves Croissant [aut, cre]
Initial release
2021-02-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.