sim.bin {ldt}R Documentation

Generate Random Sample from a DC Model

Description

This function generates a random sample from an discrete choice regression model.

Usage

sim.bin(
  coef = 2L,
  nObs = 100,
  probit = FALSE,
  maxWeight = 1,
  pPos = 0.5,
  sampleFactor = 4,
  toNumeric = TRUE
)

Arguments

coef

Either a single integer specifying the number of variables in the model, or a numeric vector of coefficients for the regression.

nObs

The number of observations to generate.

probit

Logical value indicating whether to generate data from a probit model (if TRUE) or a logit model (if FALSE).

maxWeight

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.

pPos

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.

sampleFactor

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.

toNumeric

If TRUE, y and w are transformed to have numeric vector. Otherwise, they contain an integer vector.

Value

A list with the following items:

y

The endogenous variable.

x

The exogenous variables.

w

The weights of the observations. It is NULL if weighted is FALSE.

p1

Prob(Y=1)

coef

The coefficients of the regression.

probit

Logical value indicating whether data was generated from a probit model.

pPos

The percentage of negative observations in y.

See Also

estim.bin, search.bin

Examples

# Generate data from a logit model with 3 variables
sample <- sim.bin(3L, 100)

# see the examples in 'estim.bin' or 'search.bin' functions

[Package ldt version 0.5.3 Index]