This function generates a random sample from an discrete choice regression model.
sim.bin(
coef = 2L,
nObs = 100,
probit = FALSE,
maxWeight = 1,
pPos = 0.5,
sampleFactor = 4,
toNumeric = TRUE
)A list with the following items:
The endogenous variable.
The exogenous variables.
The weights of the observations. It is NULL if weighted is FALSE.
Prob(Y=1)
The coefficients of the regression.
Logical value indicating whether data was generated from a probit model.
The percentage of negative observations in y.
Either a single integer specifying the number of variables in the model, or a numeric vector of coefficients for the regression.
The number of observations to generate.
Logical value indicating whether to generate data from a probit model
(if TRUE) or a logit model (if FALSE).
Integer value indicating the maximum weight of the observations.
If 1, observations are not weighted.
If larger than 1, a vector of weights is generated and included in the return list. The weights are drawn from a discrete uniform distribution with a maximum value determined by maxWeight.
If weighted, a larger sample is created (nObs * sampleFactor * maxWeight) and a subset of them is randomly selected, where the probability of selection is determined by the weight.
The percentage of positive observations (y=1) in the endogenous variable y.
Must be between 0 and 1.
In the current implementation, this is independent of the weights, if maxWeight is larger than 1.
The factor used to control the size of the initial sample. A larger value generates a larger initial sample, which can increase the accuracy of the generated sample but also takes more time and memory.
If TRUE, y and w are transformed to have numeric vector.
Otherwise, they contain an integer vector.
estim.bin, search.bin
# Generate data from a logit model with 3 variables
sample <- sim.bin(3L, 100)
# see the examples in 'estim.bin' or 'search.bin' functions
Run the code above in your browser using DataLab