Learn R Programming

lmreg (version 1.2)

yX: Prepare design matrix for two way layout with single oberservation per cell

Description

Prepares design matrix for two way classified data with single observation per cell and response vector in corresponding order.

Usage

yX(response, treatments, blocks)

Arguments

response

Response vector as provided (numeric).

treatments

Vector of treatment levels as provided (either numeric or character).

blocks

Vector of block levels as provided (either numeric or character).

Value

Returns a list with following components.

X

A binary matrix with number of rows equal to length of response and number of columns equal to the total number of levels of treatments and blocks plus one. Each row has exactly three 1s: in the first position and in the two positions representing the treatment and block levels.

y

Numeric vector of response values, permuted to correspond with the rows of X.

References

Sengupta and Jammalamadaka (2019), Linear Models and Regression with R: An Integrated Approach.

Examples

Run this code
# NOT RUN {
data(airspeed)
yX(airspeed$Posmaxspeed,airspeed$Reynolds,airspeed$Ribht)
# }

Run the code above in your browser using DataLab