# NOT RUN {
# see 'choicedata'
data(choicedata)
# generate dataX(convert the within-subject variables to a list)
dataX <- list()
for (i in 1:nrow(choicedata)){
logP <- as.numeric(log(choicedata[i,3:8]))
# all numeric variables must be mean centered
dataX[[i]] <- as.data.frame(logP) - mean(logP)
}
dataZ <- choicedata[,9:13]
# }
# NOT RUN {
res <- BANOVA.Multinomial(~ logP, ~ college, dataX, dataZ,
choicedata$choice, choicedata$hhid, burnin = 100, sample = 100, thin = 10)
# or use BANOVA.run based on 'Stan'
require(rstan)
res <- BANOVA.run(~ logP, ~ college, dataX = dataX, dataZ = dataZ,
model_name = 'Multinomial', y_value = choicedata$choice,
id = choicedata$hhid, iter = 100, thin = 1, chains = 2)
# }
Run the code above in your browser using DataLab