| simulate_metafrontier | R Documentation |
Generates synthetic data from a known metafrontier data-generating process. Each group frontier lies weakly below the metafrontier, consistent with groups facing different restrictions of a common metatechnology (Battese, Rao and O'Donnell, 2004). Useful for Monte Carlo simulations, package testing, and teaching.
simulate_metafrontier(
n_groups = 2L,
n_per_group = 100L,
n_inputs = 2L,
beta_meta = NULL,
tech_gap = NULL,
sigma_u = NULL,
sigma_v = 0.2,
seed = NULL,
beta_groups = NULL,
input_means = NULL,
input_corr = NULL
)
n_groups |
integer. Number of technology groups (default 2). |
n_per_group |
integer or integer vector. Number of observations
per group. If a single value, the same number is used for all
groups. If a vector, must be of length |
n_inputs |
integer. Number of input variables (default 2). |
beta_meta |
numeric vector. Metafrontier coefficients
(including intercept). Length must be |
tech_gap |
numeric vector of length |
sigma_u |
numeric vector of length |
sigma_v |
numeric. Standard deviation of the symmetric noise term. Default: 0.2. |
seed |
integer or |
beta_groups |
optional group-specific frontier coefficients,
including slopes: either an |
input_means |
optional |
input_corr |
optional |
By default the group frontiers share the metafrontier slopes and
differ only in their intercepts, so the true technology gap ratio
(TGR) is constant within each group and equals
exp(-tech_gap[g]). When beta_groups is supplied the
group frontiers may differ in their slopes, in which case no single
log-linear metafrontier envelops all groups: the tightest log-linear
envelope is then a pseudo-true quantity. The returned
true_tgr is instead computed observation by observation
against the pointwise maximum over the group frontiers,
TGR_i = \exp(x_i^\top \beta_g - \max_j x_i^\top \beta_j), which is
guaranteed to lie in (0, 1]. The true group frontier for each firm
is x_i^\top \beta_g, true_te is generated exactly as in the
default design, and true_te_star = true_te * true_tgr. In
this case params$beta_meta is NULL and
params$beta_groups holds the supplied coefficients.
By default the log-inputs are drawn i.i.d. from a uniform
distribution on [0, 5], identically across groups. Supplying
input_means and/or input_corr switches to normal
log-inputs with standard deviation 5 / sqrt(12) (matching the
spread of the uniform draws), centred at input_means[g, ]
(2.5 for every group and input when input_means is
NULL). When input_corr is supplied the draws are
multivariate normal with that correlation matrix; when it is
NULL but input_means is given, the inputs are drawn
independently.
A list with components:
a data frame with columns log_y, log_x1,
log_x2, ..., group, and the true underlying values
a list of the true parameters used for generation
sim <- simulate_metafrontier(n_groups = 3, n_per_group = 200,
sigma_u = c(0.2, 0.4, 0.3))
str(sim$data)
table(sim$data$group)
# The true metafrontier coefficients
sim$params$beta_meta
# Group-specific slopes: per-observation true TGR
sim2 <- simulate_metafrontier(
beta_groups = rbind(c(1.0, 0.5, 0.2), c(0.9, 0.6, 0.1))
)
range(sim2$data$true_tgr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.