Learn R Programming

LMest (version 2.4.5)

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)

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)

Examples

Run this code
# NOT RUN {
# 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