View source: R/estimateModels.R
| estimateModels | R Documentation |
This function estimates the same model multiple times using different size
subsets of a set of choice data. The number of models to run is set by the
nbreaks argument, which breaks up the data into groups of increasing
sample sizes. All models are estimated models using the logitr package.
estimateModels(
nbreaks = 10,
nQPerResp = 1,
data,
outcome,
obsID,
pars,
price = NULL,
randPars = NULL,
randPrice = NULL,
modelSpace = "pref",
weights = NULL,
panelID = NULL,
clusterID = NULL,
robust = FALSE,
startParBounds = c(-1, 1),
startVals = NULL,
numMultiStarts = 1,
useAnalyticGrad = TRUE,
scaleInputs = TRUE,
standardDraws = NULL,
numDraws = 50,
vcov = FALSE,
predict = FALSE,
options = list(print_level = 0, xtol_rel = 1e-06, xtol_abs = 1e-06, ftol_rel = 1e-06,
ftol_abs = 1e-06, maxeval = 1000, algorithm = "NLOPT_LD_LBFGS")
)
nbreaks |
The number of different sample size groups. |
nQPerResp |
Number of questions per respondent. Defaults to |
data |
The data, formatted as a |
outcome |
The name of the column that identifies the outcome variable,
which should be coded with a |
obsID |
The name of the column that identifies each observation. |
pars |
The names of the parameters to be estimated in the model.
Must be the same as the column names in the |
price |
The name of the column that identifies the price variable.
Required for WTP space models. Defaults to |
randPars |
A named vector whose names are the random parameters and
values the distribution: |
randPrice |
The random distribution for the price parameter: |
modelSpace |
Set to |
weights |
The name of the column that identifies the weights to be
used in model estimation. Defaults to |
panelID |
The name of the column that identifies the individual (for
panel data where multiple observations are recorded for each individual).
Defaults to |
clusterID |
The name of the column that identifies the cluster
groups to be used in model estimation. Defaults to |
robust |
Determines whether or not a robust covariance matrix is
estimated. Defaults to |
startParBounds |
sets the |
startVals |
is vector of values to be used as starting values for the
optimization. Only used for the first run if |
numMultiStarts |
is the number of times to run the optimization loop,
each time starting from a different random starting point for each parameter
between |
useAnalyticGrad |
Set to |
scaleInputs |
By default each variable in |
standardDraws |
By default, a new set of standard normal draws are
generated during each call to |
numDraws |
The number of Halton draws to use for MXL models for the
maximum simulated likelihood. Defaults to |
vcov |
Set to |
predict |
If |
options |
A list of options for controlling the |
Returns a nested data frame with each estimated model object in
the model column.
library(conjointTools)
# Define the attributes and levels
levels <- list(
price = seq(1, 4, 0.5), # $ per pound
type = c('Fuji', 'Gala', 'Honeycrisp', 'Pink Lady', 'Red Delicious'),
freshness = c('Excellent', 'Average', 'Poor')
)
# Make a full-factorial design of experiment and recode the levels
doe <- makeDoe(levels)
doe <- recodeDoe(doe, levels)
# Make the survey
survey <- makeSurvey(
doe = doe, # Design of experiment
nResp = 2000, # Total number of respondents (upper bound)
nAltsPerQ = 3, # Number of alternatives per question
nQPerResp = 6 # Number of questions per respondent
)
# Simulate random choices for the survey
data <- simulateChoices(
survey = survey,
obsID = "obsID"
)
# Estimate models with different sample sizes
models <- estimateModels(
nbreaks = 10,
data = data,
pars = c("price", "type", "freshness"),
outcome = "choice",
obsID = "obsID"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.