Skip to contents

Generate data following Klein & Vella (2010) assumptions

Usage

generate_klein_vella_data(config, return_true_values = FALSE)

Arguments

config

Configuration object from create_klein_vella_config or a list

return_true_values

Whether to return true variance functions

Value

Data frame with generated data

Details

Generates data from the triangular system: Y1 = X'beta1 + gamma1*Y2 + epsilon1 Y2 = X'beta2 + epsilon2

where the errors have:

  • Constant conditional correlation: Corr(epsilon1, epsilon2 | X) = rho

  • Heteroskedastic variances: Var(epsilon_j | X) = exp(X'delta_j)

Examples

config <- create_klein_vella_config(
  n = 1000,
  beta1 = c(0.5, 1.5),
  beta2 = c(1.0, -1.0),
  gamma1 = -0.8,
  rho = 0.6,
  delta1 = c(0.1, 0.3),
  delta2 = c(0.2, -0.2)
)
#> Klein & Vella configuration created:
#>   Sample size: 1000
#>   Number of X variables: 1
#>   True gamma1: -0.800
#>   Error correlation: 0.600
data <- generate_klein_vella_data(config)
head(data)
#>          Y1         Y2           X
#> 1  5.198347 -1.1987349  2.06502490
#> 2 -3.417525  3.0501819 -1.63098940
#> 3  2.424502  0.1471646  0.51242695
#> 4 -4.240481  1.8199738 -1.86301149
#> 5 -2.566945  1.5009520 -0.52201251
#> 6  0.667024  0.8646222 -0.05260191