if (FALSE) {
# Basic Markov Chain model
data("RLMSlong")
# Categories rescaled from 1 “absolutely unsatisfied” to 5 “absolutely satisfied”
RLMSlong$value <- 5 - RLMSlong$value
out <- lmestMc(responsesFormula = value ~ NULL,
index = c("id","time"),
modBasic = 1,
data = RLMSlong)
out
summary(out)
# Example of drug consumption data
data("data_drug")
long <- data_drug[,-6]
long <- data.frame(id = 1:nrow(long),long)
long <- reshape(long,direction = "long",
idvar = "id",
varying = list(2:ncol(long)))
out1 <- lmestMc(index = c("id","time"), data = long,
weights = data_drug[,6], modBasic = 1, out_se = TRUE)
out1
### MC model with covariates
### Covariates: gender, race, educational level (2 columns), age and age^2
data("data_SRHS_long")
SRHS <- data_SRHS_long[1:2400,]
# Categories of the responses rescaled from 1 “poor” to 5 “excellent”
SRHS$srhs <- 5 - SRHS$srhs
out2 <- lmestMc(responsesFormula = srhs ~
I( 0 + (race==2) + (race == 3)) +
I(0 + (education == 4)) +
I(0 + (education == 5)) +
I(age - 50) +
I((age-50)^2/100),
index = c("id","t"),
data = SRHS)
out2
summary(out2)
# Criminal data
data(data_criminal_sim)
data_criminal_sim = data.frame(data_criminal_sim)
out3 <- lmestMc(responsesFormula = y5~sex,
index = c("id","time"),
data = data_criminal_sim,
output = TRUE)
out3
}
Run the code above in your browser using DataLab