simulate_metafrontier: Simulate Metafrontier Data

View source: R/simulate.R

simulate_metafrontierR Documentation

Simulate Metafrontier Data

Description

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.

Usage

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
)

Arguments

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_groups.

n_inputs

integer. Number of input variables (default 2).

beta_meta

numeric vector. Metafrontier coefficients (including intercept). Length must be n_inputs + 1. Default: c(1.0, seq(0.5, 0.2, length.out = n_inputs)), i.e. c(1.0, 0.5, 0.2) for the default two inputs. Ignored when beta_groups is supplied.

tech_gap

numeric vector of length n_groups. The technology gap for each group, defined as the reduction in the intercept relative to the metafrontier. Default: evenly spaced from 0 to 0.5. Ignored (with a warning) when beta_groups is supplied.

sigma_u

numeric vector of length n_groups. Standard deviation of the half-normal inefficiency term for each group. Default: rep(0.3, n_groups).

sigma_v

numeric. Standard deviation of the symmetric noise term. Default: 0.2.

seed

integer or NULL. Random seed for reproducibility.

beta_groups

optional group-specific frontier coefficients, including slopes: either an n_groups x (n_inputs + 1) numeric matrix (one row per group) or a list of n_groups numeric vectors of length n_inputs + 1. When supplied, it replaces the intercept-shift construction based on tech_gap; see Details. Default NULL (intercept-shift design).

input_means

optional n_groups x n_inputs numeric matrix of per-group mean log-input levels. When supplied, the log-inputs for group g are drawn from a normal distribution centred at input_means[g, ]; see Details. Default NULL (identical uniform inputs across groups).

input_corr

optional n_inputs x n_inputs correlation matrix for the log-inputs. When supplied, the log-inputs are drawn from a multivariate normal distribution with this correlation structure; see Details. Default NULL (independent inputs).

Details

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.

Value

A list with components:

data

a data frame with columns log_y, log_x1, log_x2, ..., group, and the true underlying values

params

a list of the true parameters used for generation

Examples

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)


metafrontier documentation built on Aug. 19, 2026, 5:08 p.m.