margarine: Household Panel Data on Margarine Purchases

Description Usage Format Details Source References Examples

Description

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

Usage

1

Format

The detailing object is a list containing two data frames, choicePrice and demos.

Details

In the choicePrice data frame:

...$hhid household ID
...$choice multinomial indicator of one of the 10 products

The products are indicated by brand and type.

Brands:

...$Pk Parkay
...$BB BlueBonnett
...$Fl Fleischmanns
...$Hse house
...$Gen generic
...$Imp Imperial
...$SS Shed Spread

Product type:

...$_Stk stick
...$_Tub tub

In the demos data frame:

...$Fs3_4 dummy for family size 3-4
...$Fs5 dummy for family size >= 5
...$college dummy for education status
...$whtcollar dummy for job status
...$retired dummy for retirement status

All prices are in U.S. dollars.

Source

Allenby, Greg and Peter Rossi (1991), "Quality Perceptions and Asymmetric Switching Between Brands," Marketing Science 10, 185–205.

References

Chapter 5, Bayesian Statistics and Marketing by Rossi, Allenby, and McCulloch.
http://www.perossi.org/home/bsm-1

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
data(margarine)
cat(" Table of Choice Variable ", fill=TRUE)
print(table(margarine$choicePrice[,2]))

cat(" Means of Prices", fill=TRUE)
mat=apply(as.matrix(margarine$choicePrice[,3:12]), 2, mean)
print(mat)

cat(" Quantiles of Demographic Variables", fill=TRUE)
mat=apply(as.matrix(margarine$demos[,2:8]), 2, quantile)
print(mat)


## example of processing for use with 'rhierMnlRwMixture'
if(0) {
  select = c(1:5,7)  ## select brands
  chPr = as.matrix(margarine$choicePrice)
  
  ## make sure to log prices
  chPr = cbind(chPr[,1], chPr[,2], log(chPr[,2+select]))
  demos = as.matrix(margarine$demos[,c(1,2,5)])
  
  ## remove obs for other alts
  chPr = chPr[chPr[,2] <= 7,]
  chPr = chPr[chPr[,2] != 6,]
  
  ## recode choice
  chPr[chPr[,2] == 7,2] = 6
  
  hhidl = levels(as.factor(chPr[,1]))
  lgtdata = NULL
  nlgt = length(hhidl)
  p = length(select)  ## number of choice alts
  
  ind = 1
  for (i in 1:nlgt) {
    nobs = sum(chPr[,1]==hhidl[i])
    if(nobs >=5) {
      data = chPr[chPr[,1]==hhidl[i],]
      y = data[,2]
      names(y) = NULL
      X = createX(p=p, na=1, Xa=data[,3:8], nd=NULL, Xd=NULL, INT=TRUE, base=1)
      lgtdata[[ind]] = list(y=y, X=X, hhid=hhidl[i])
      ind = ind+1
    }
  }
  nlgt = length(lgtdata)
  
  ## now extract demos corresponding to hhs in lgtdata
  Z = NULL
  nlgt = length(lgtdata)
  for(i in 1:nlgt){
     Z = rbind(Z, demos[demos[,1]==lgtdata[[i]]$hhid, 2:3])
  }
  
  ## take log of income and family size and demean
  Z = log(Z)
  Z[,1] = Z[,1] - mean(Z[,1])
  Z[,2] = Z[,2] - mean(Z[,2])
  
  keep = 5
  R = 20000
  mcmc1 = list(keep=keep, R=R)
  
  out = rhierMnlRwMixture(Data=list(p=p,lgtdata=lgtdata, Z=Z),
                          Prior=list(ncomp=1), Mcmc=mcmc1)
  
  summary(out$Deltadraw)
  summary(out$nmix)
  
  ## plotting examples
  if(0){
    plot(out$nmix)
    plot(out$Deltadraw)
  }
}

Example output

 Table of Choice Variable 

   1    2    3    4    5    6    7    8    9   10 
1766  699  243  593  315   74  319  203  225   33 
 Means of Prices
  PPk_Stk   PBB_Stk   PFl_Stk  PHse_Stk  PGen_Stk  PImp_Stk   PSS_Tub   PPk_Tub 
0.5184362 0.5432103 1.0150201 0.4371477 0.3452819 0.7807785 0.8250895 1.0774094 
  PFl_Tub  PHse_Tub 
1.1893758 0.5686734 
 Quantiles of Demographic Variables
     Income Fs3_4 Fs5. Fam_Size college whtcollar retired
0%      2.5     0    0        1       0         0       0
25%    17.5     0    0        2       0         0       0
50%    22.5     0    0        3       0         1       0
75%    32.5     1    0        4       1         1       0
100%  130.0     1    1        8       1         1       1

bayesm documentation built on July 21, 2017, 7:18 p.m.