View source: R/stratEst_simulate.R
stratEst.simulate | R Documentation |
The simulation function of the package.
stratEst.simulate( data = NULL, strategies, shares = NULL, coefficients = NULL, covariate.mat = NULL, num.ids = 100, num.games = 5, num.periods = NULL, fixed.assignment = TRUE, input.na = FALSE, sample.id = NULL )
data |
a |
strategies |
a list of strategies. Each element if the list must be an object of class |
shares |
a numeric vector of strategy shares. The order of the elements corresponds to the order in |
coefficients |
a matrix of regression coefficients. Column names correspond to the names of the strategies, row names to the names of the covariates. |
covariate.mat |
a matrix with the covariates in columns. The column names of the matrix indicate the names of the covariates. The matrix must have as many rows as there are individuals. |
num.ids |
an integer. The number of individuals. Default is 100. |
num.games |
an integer. The number of games. Default is 5. |
num.periods |
a vector of integers with as many elements |
fixed.assignment |
a logical value. If |
input.na |
a logical value. If |
sample.id |
a character string indicating the name of the variable which identifies the samples in data. Individual observations must be nested in samples. Default is |
A stratEst.data
object. A data frame in the long format with the following variables:
id |
the variable that identifies observations of the same individual. |
game |
the variable that identifies observations of the same game. |
period |
the period of the game. |
choice |
the discrete choices. |
input |
the inputs. |
sample |
the sample of the individual. |
strategy |
the strategy of the individual. |
## Simulate data of two strategies for choices "left" and "right". lr <- c("left","right") pi <- runif(1) pr <- c(1,0,0,1) tr <- c(1,2,1,2) mixed <- stratEst.strategy(choices = lr, inputs = lr, prob.choices = c(pi, 1 - pi)) pure <- stratEst.strategy(choices = lr, inputs = lr, prob.choices = pr, tr.inputs = tr) gamma <- runif(1)/4 pure$tremble <- gamma beta <- rnorm(1) p <- 1/sum(1 + exp(beta)) sim.shares <- c(p, 1-p) sim.strategies <- list("mixed" = mixed, "pure" = pure) sim.data <- stratEst.simulate(strategies = sim.strategies, shares = sim.shares)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.