@@ -134,34 +134,33 @@ wtpCompare(mxl.pref, mxl.wtp, priceName='price')
134
134
# ============================================================================
135
135
# Run Market Simulation Using Estimated Models
136
136
137
- # Create a market to simulate. Each row is an alternative and each column an
138
- # attribute. In this example, I just use one of the choice observations from
139
- # the yogurt dataset:
140
- market = subset(yogurt , obsID == 42 ,
141
- select = c(' feat' , ' price' , ' dannon' , ' hiland' , ' yoplait' ))
142
- row.names(market ) = c(' dannon' , ' hiland' , ' weight' , ' yoplait' )
143
- market
137
+ # Create a set of alternatives for which to simulate shares. Each row is an
138
+ # alternative and each column an attribute. In this example, I just use one of the choice observations from the yogurt dataset:
139
+ alts = subset(yogurt , obsID == 42 ,
140
+ select = c(' feat' , ' price' , ' dannon' , ' hiland' , ' yoplait' ))
141
+ row.names(alts ) = c(' dannon' , ' hiland' , ' weight' , ' yoplait' )
142
+ alts
144
143
145
144
# Run the simulation using the preference space MNL model:
146
- mnl.pref.simulation = marketSimulation (mnl.pref , market , alpha = 0.025 )
145
+ mnl.pref.simulation = simulateShares (mnl.pref , alts , alpha = 0.025 )
147
146
mnl.pref.simulation
148
- # The results show the expected market shares for each alternative.
147
+ # The results show the expected shares for each alternative.
149
148
# The low and high values show a 95% confidence interval, estimated using
150
149
# simulation. You can change the CI level by setting alpha to a different
151
150
# value (e.g. a 90% CI is obtained with alpha=0.05).
152
151
153
152
# Run the simulation using the WTP space MNL model:
154
- mnl.wtp.simulation = marketSimulation (mnl.wtp , market , priceName = ' price' )
153
+ mnl.wtp.simulation = simulateShares (mnl.wtp , alts , priceName = ' price' )
155
154
mnl.wtp.simulation
156
155
# Since these two models are equivalent except in different spaces, the
157
156
# simulation results should be the same. Note that 'priceName' is the name
158
- # of the price attribute in the market argument and must be included for
157
+ # of the price attribute in the alts argument and must be included for
159
158
# WTP space models.
160
159
161
- # Market simulations can also be run using MXL models in either space:
162
- mxl.pref.simulation = marketSimulation (mxl.pref , market , alpha = 0.025 )
160
+ # Simulations can also be run using MXL models in either space:
161
+ mxl.pref.simulation = simulateShares (mxl.pref , alts )
163
162
mxl.pref.simulation
164
- mxl.wtp.simulation = marketSimulation (mxl.wtp , market , priceName = ' price' , alpha = 0.025 )
163
+ mxl.wtp.simulation = simulateShares (mxl.wtp , alts , priceName = ' price' )
165
164
mxl.wtp.simulation
166
165
167
166
# Plot simulation results from preference space MNL model:
0 commit comments