long2matrices {LMest} | R Documentation |
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)
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 |
Value
XX |
array of covariates (n x TT x nc) |
YY |
array of responses (n x TT x r) |
Author(s)
Francesco Bartolucci, Silvia Pandolfi, University of Perugia (IT), http://www.stat.unipg.it/bartolucci
Examples
# 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)
[Package LMest version 3.1.2 Index]