Learn R Programming

LMest (version 3.1.2)

long2matrices: From data in the long format to data in array format

Description

Function that transforms data in the long format to data in array format.

Usage

long2matrices(id, time = NULL, X = NULL, Y)

Value

XX

array of covariates (n x TT x nc)

YY

array of responses (n x TT x r)

Arguments

id

vector of subjects id

time

vector of time occasions

X

matrix of covariates in long format

Y

matrix of responses in long format

Author

Francesco Bartolucci, Silvia Pandolfi, University of Perugia (IT), http://www.stat.unipg.it/bartolucci

Examples

Run this code
# Example based on SRHS data

# load SRHS data
data(data_SRHS_long)
dataSRHS <- data_SRHS_long[1:1600,]
head(dataSRHS)
X <- cbind(dataSRHS$gender-1, dataSRHS$race == 2 | dataSRHS$race == 3,
dataSRHS$education == 4,dataSRHS$education == 5, dataSRHS$age-50,
(dataSRHS$age-50)^2/100)
Y <- dataSRHS$srhs
res <- long2matrices(dataSRHS$id, X = X, Y = Y)

Run the code above in your browser using DataLab