Learn R Programming

BANOVA (version 1.2.1)

choicedata: Household Panel Data on Margarine Purchases

Description

Panel data on purchases of margarine by 204 households. Demographic variables are included.

Usage

data(choicedata)

Arguments

Format

This is an R object that contains within-subjects variables and between-subjects variables:

$ choicePrice:`data.frame': 1500 obs. of 13 variables: … $ hhid : int 2100016 2100016 2100016 2100016 … $ choice : int 1 1 1 1 1 4 1 1 4 1

Within-subject variables:

… $ PPk_Stk : num 0.66 0.63 0.29 0.62 0.5 0.58 0.29 ... … $ PBB_Stk : num 0.67 0.67 0.5 0.61 0.58 0.45 0.51 ... … $ PFl_Stk : num 1.09 0.99 0.99 0.99 0.99 0.99 0.99 ... … $ PHse_Stk: num 0.57 0.57 0.57 0.57 0.45 0.45 0.29 ... … $ PGen_Stk: num 0.36 0.36 0.36 0.36 0.33 0.33 0.33 ... … $ PSS_Tub : num 0.85 0.85 0.79 0.85 0.85 0.85 0.85 ...

Pk is Parkay; BB is BlueBonnett, Fl is Fleischmanns, Hse is house, Gen is generic, SS is Shed Spread. _Stk indicates stick, _Tub indicates Tub form.

Between-subject variables:

… $ Income : num 32.5 17.5 37.5 17.5 87.5 12.5 ... … $ Fam_Size : int 2 3 2 1 1 2 2 2 5 2 ... … $ college : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ... … $ whtcollar: Factor w/ 2 levels "0","1": 0 0 0 0 0 0 0 1 1 1 ... … $ retired : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...

Details

choice is a multinomial indicator of one of the 6 brands (in order listed under format). All prices are in $.

References

Chapter 5, Bayesian Statistics and Marketing by Rossi et al.

Examples

Run this code
# NOT RUN {
data(choicedata)
# generate dataX(convert the within-subjects variables to a list)
dataX <- list()
for (i in 1:nrow(choicedata)){
  logP <- as.numeric(log(choicedata[i,3:8]))
  # Note: Before the model initialization, all numeric variables(covariates) 
  # must be mean centered
  dataX[[i]] <- as.data.frame(logP) - mean(logP)
}
dataZ <- choicedata[,9:13]
res <- BANOVA.Multinomial(~ logP, ~ college, dataX, dataZ, choicedata$choice, 
choicedata$hhid, burnin = 100, sample = 100, thin = 1)
summary(res)
predict(res,dataX[1:4], dataZ[1:4,])
# }

Run the code above in your browser using DataLab