matrices2long {LMest} | R Documentation |
From data in array format to data in long format
Description
Function to convert data with array format in data with long format.
Usage
matrices2long(Y, X1 = NULL, X2 = NULL)
Arguments
Y |
array of responses ( |
X1 |
array of covariates ( |
X2 |
array of covariates ( |
Details
Y
, X1
and X2
must have the same number of observations.
Value
Returns a data.frame
with data in long format. The first column indicates the name of the unit identifier, and the second column indicates the time occasions.
Author(s)
Francesco Bartolucci, Silvia Pandolfi, Fulvia Pennoni, Alessio Farcomeni, Alessio Serafini
Examples
### Example with data on self rated health
data(data_SRHS_long)
SRHS <- data_SRHS_long[1:1600,]
# Covariates
X <- cbind(SRHS$gender-1,
SRHS$race == 2 | SRHS$race == 3,
SRHS$education == 4,
SRHS$education == 5,
SRHS$age-50,
(SRHS$age-50)^2/100)
# Responses
Y <- SRHS$srhs
res <- long2matrices(SRHS$id, X = X, Y = Y)
long <- matrices2long(Y = res$YY, X1 = res$XX)
[Package LMest version 3.1.2 Index]