mdcev.sim: mdcev.sim

View source: R/mdcev.sim.R

mdcev.simR Documentation

mdcev.sim

Description

Simulate welfare or demand for MDCEV model

Usage

mdcev.sim(
  df_indiv,
  df_common,
  sim_options,
  sim_type = c("welfare", "demand"),
  nerrs = 30,
  cond_error = 1,
  draw_mlhs = 1,
  algo_gen = NULL,
  tol = 1e-20,
  max_loop = 999,
  suppressTime = FALSE,
  stan_seed = 3,
  ...
)

## S3 method for class 'mdcev.sim'
print(
  x,
  digits = max(3, getOption("digits") - 3),
  width = getOption("width"),
  ...
)

## S3 method for class 'mdcev.sim'
summary(object, ci = 0.95, ...)

## S3 method for class 'summary.mdcev.sim'
print(
  x,
  digits = max(3, getOption("digits") - 2),
  width = getOption("width"),
  ...
)

Arguments

df_indiv

Prepared individual level data from PrepareSimulationData

df_common

Prepared common data from PrepareSimulationData

sim_options

Prepared simulation options from PrepareSimulationData

sim_type

Either "welfare" or "demand"

nerrs

Number of error draws for welfare analysis

cond_error

Choose whether to draw errors conditional on actual demand or not. Conditional error draws (=1) or unconditional error draws.

draw_mlhs

Generate draws using Modified Latin Hypercube Sampling algorithm (=1) or uniform (=0)

algo_gen

Type of algorithm for simulation. algo_gen = 0 for Hybrid Approach (i.e. constant alphas, only hybrid models) algo_gen = 1 for General approach (i.e. heterogeneous alpha's, all models)

tol

Tolerance level for simulations if using general approach

max_loop

maximum number of loops for simulations if using general approach

suppressTime

Suppress simulation time calculation

stan_seed

Seed for pseudo-random number generator get_rng see help(get_rng, package = "rstan")

...

Additional parameters to pass to mdcev.sim

x, object

an object of class 'mdcev.sim'

digits

the number of digits,

width

the width of the printing,

ci

choose confidence interval for simulations. Default is 95 percent.

Value

a object of class mdcev.sim which contains a list for each individual holding either 1) nsims x npols matrix of welfare changes if welfare is being simulated or 2) nsims number of lists of npols x # alternatives matrix of Marshallian demands is demand is being simulated.

See Also

[mdcev()] for the estimation of mdcev models.

Examples


data(data_rec, package = "rmdcev")

data_rec <- mdcev.data(data_rec, subset = id <= 500, id.var = "id",
                alt.var = "alt", choice = "quant")

mdcev_est <- mdcev( ~ 0, data = data_rec,
               model = "hybrid0", algorithm = "MLE",
               std_errors = "mvn")

policies <- CreateBlankPolicies(npols = 2,
             mdcev_est,
             price_change_only = TRUE)

df_sim <- PrepareSimulationData(mdcev_est, policies)

wtp <- mdcev.sim(df_sim$df_indiv,
                 df_common = df_sim$df_common,
                 sim_options = df_sim$sim_options,
                 cond_err = 1, nerrs = 5, sim_type = "welfare")


rmdcev documentation built on March 31, 2023, 6:49 p.m.