metafrontier: Estimate a Metafrontier Production Function

View source: R/metafrontier.R

metafrontierR Documentation

Estimate a Metafrontier Production Function

Description

Estimates group-specific frontiers and a metafrontier that envelops all group technologies. Supports both SFA-based (parametric) and DEA-based (nonparametric) approaches, with deterministic (Battese, Rao, and O'Donnell, 2004) or stochastic (Huang, Huang, and Liu, 2014) metafrontier estimation.

Usage

metafrontier(
  formula = NULL,
  data = NULL,
  group = NULL,
  method = c("sfa", "dea"),
  meta_type = c("deterministic", "stochastic"),
  dist = c("hnormal", "tnormal", "exponential"),
  orientation = c("output", "input"),
  rts = c("crs", "vrs", "drs", "irs", "fdh"),
  models = NULL,
  panel = NULL,
  panel_dist = c("bc92", "bc95"),
  type = c("radial", "directional", "hyperbolic"),
  direction = c("proportional", "output", "input"),
  control = list(),
  estimator = c("bc88", "jlms"),
  objective = c("lp", "qp"),
  engine = c("internal", "sfaR", "frontier", "Benchmarking"),
  slack = FALSE,
  frontier = c("production", "cost"),
  selection = NULL,
  spatial = NULL,
  ...
)

Arguments

formula

an object of class Formula. The left-hand side specifies the (log) output variable. The first right-hand side part specifies inputs for the frontier. An optional second part (separated by |) specifies inefficiency determinants. Example: log_y ~ log_x1 + log_x2 | z1 + z2. Ignored if models is provided.

data

a data frame containing all variables in the formula and the grouping variable. Ignored if models is provided.

group

a character string naming the column in data that identifies technology groups, or a vector of group indicators of length nrow(data). Ignored if models is provided.

method

character. The frontier estimation method for group-specific models: "sfa" (default) for stochastic frontier analysis or "dea" for data envelopment analysis.

meta_type

character. The method for estimating the metafrontier: "deterministic" (default) uses the linear programming approach of Battese, Rao, and O'Donnell (2004); "stochastic" uses the second-stage SFA approach of Huang, Huang, and Liu (2014).

dist

character. Distribution of the one-sided inefficiency term in SFA models. One of "hnormal" (half-normal, default), "tnormal" (truncated normal), or "exponential". Ignored when method = "dea".

orientation

character. For DEA: "output" (default) or "input" orientation. Ignored when method = "sfa".

rts

character. Returns to scale for DEA: "crs" (constant, default), "vrs" (variable), "drs" (decreasing), "irs" (increasing), or "fdh" (free disposable hull, i.e. no convexity). Ignored when method = "sfa".

models

an optional named list of pre-fitted group-specific frontier models (objects from sfaR or frontier, or hand-built lists). Fitted model objects are converted automatically via as_metafrontier_model, so no manual conversion is required (pre-converting is harmless, the conversion is idempotent). Farrell objects from Benchmarking store neither coefficients nor data and cannot be used here; use the formula interface with method = "dea" instead. If models is provided, formula, data, and group are ignored.

panel

an optional list with components id and time naming the panel identifier and time columns in data. When non-NULL, panel SFA models (BC92/BC95) are used at the group level.

panel_dist

character. Panel SFA model: "bc92" (Battese and Coelli 1992, time-varying inefficiency, default) or "bc95" (Battese and Coelli 1995, observation-specific mean). Only used when panel is non-NULL.

type

character. For DEA: "radial" (default) for standard radial DEA, "directional" for directional distance functions, or "hyperbolic" for hyperbolic (graph) efficiency, which contracts inputs and expands outputs simultaneously.

direction

direction vector for DDF. Either a character preset ("proportional" (default), "output", or "input"), a numeric vector of length m + s giving a common direction (first m elements for inputs, last s for outputs), or a numeric n x (m + s) matrix of firm-specific directions. With numeric directions the ratio-based TGR is not defined; the additive gap (ddf_gap) is reported instead. Only used when type = "directional".

control

a named list of control parameters passed to optim. Common options include maxit (maximum iterations, default 5000), reltol (relative convergence tolerance, default 1e-10), and fnscale (set to -1 internally for maximisation).

estimator

character. Technical efficiency estimator for SFA models: "bc88" (default) for the conditional expectation E[\exp(-u)|\varepsilon] of Battese and Coelli (1988), which is the consistent estimator of technical efficiency, or "jlms" for \exp(-E[u|\varepsilon]) following Jondrow et al. (1982). Both are stored on the fitted object; see efficiencies. Ignored when method = "dea".

objective

character. Identification criterion for the deterministic metafrontier: "lp" (default) minimises the sum of absolute deviations (a linear programme), "qp" minimises the sum of squared deviations (a quadratic programme, solved exactly via quadprog when available). Both criteria are proposed in Battese, Rao, and O'Donnell (2004). Only used when method = "sfa" and meta_type = "deterministic".

engine

character. Estimation backend for the group frontiers: "internal" (default) uses the package's own estimators; "sfaR" or "frontier" delegate the SFA group frontiers to sfacross or sfa (cross-sectional, single-part formulas only); "Benchmarking" delegates the DEA group frontiers and the pooled metafrontier to dea (radial only), using its XREF/YREF external-reference facility for the metafrontier stage. The metafrontier stage for SFA methods is always estimated internally (the Murphy-Topel correction requires the internal likelihood).

slack

logical. For radial DEA, compute second-stage input and output slacks (with the radial score held fixed) against both the group and the pooled reference sets. Default FALSE.

frontier

character. "production" (default), with composed error \varepsilon = v - u, or "cost", with \varepsilon = v + u and a cost metafrontier that lies on or below every group cost frontier. Efficiencies and technology gap ratios lie in (0, 1] in both cases. SFA methods only.

selection

an optional two-sided formula d ~ z1 + z2 naming a 0/1 selection indicator and its regressors. Each group frontier is then estimated as the sample-selection stochastic frontier of Greene (2010): a probit selection equation, and a frontier observed when d = 1 whose noise is correlated (rho) with the selection error. Rows with d = 0 enter only the probit and may have a missing outcome; efficiencies and technology gap ratios are reported for the selected rows. Half-normal or exponential inefficiency; cross-sectional SFA with the internal engine only.

spatial

an optional list list(W = , row_standardise = FALSE). W is an n x n spatial weights matrix for the rows of data (a matrix, a Matrix matrix or an spdep listw object) with a zero diagonal. Each group frontier is then the spatial-autoregressive stochastic frontier y = \rho_g W_g y + x'\beta_g + v - u (Glass, Kenjegalieva and Sickles, 2016), where W_g is the block of W for the group's own units (re-row-standardised when row_standardise = TRUE), so spillovers between groups are excluded. Each group model reports rho and the direct, indirect and total input effects (effects). The metafrontier envelops the long-run group frontiers m_g x'\beta_g, with m_g the mean row sum of (I - \rho_g W_g)^{-1} (1 / (1 - \rho_g) for row-standardised weights): with row-standardised weights the intercept and \rho_g are nearly collinear, so the direct technology x'\beta_g is poorly determined while the long-run frontier is not. Cross-sectional SFA without inefficiency determinants, internal engine only.

...

additional arguments passed to the group-level estimation functions.

Details

The metafrontier framework decomposes efficiency relative to a global technology into two components:

TE^*_i = TE_i \times TGR_i

where TE_i is efficiency relative to the group frontier and TGR_i is the technology gap ratio measuring how close the group frontier is to the metafrontier.

The deterministic metafrontier is identified by one of the two criteria proposed by Battese, Rao, and O'Donnell (2004), subject in both cases to the constraint that the metafrontier envelops all group frontiers: minimising the sum of absolute deviations, which reduces to a linear programme because the envelope constraints force every deviation to be non-negative (O'Donnell, Rao, and Battese, 2008, Eqs. 23-25), or minimising the sum of squared deviations, a convex quadratic programme. The LP (objective = "lp", the default) is solved via lpSolveAPI; the QP (objective = "qp") is solved exactly via quadprog when available, with an adaptive-barrier fallback via constrOptim(). The stochastic metafrontier (Huang, Huang, and Liu, 2014) replaces this with a second-stage SFA, providing a distributional framework for inference on the TGR.

Convergence and failure handling: estimation stops with an error only when no usable estimate exists (for example, when both the BFGS and Nelder-Mead optimisers fail for a group frontier). When an optimiser stops at a non-zero convergence code, the fitted object is returned with a warning and the code is recorded; use check_convergence or summary() to verify all estimation stages before interpreting technology gap ratios, confidence intervals, or productivity decompositions. Infeasible DEA programmes yield NA efficiency scores, accompanied by a warning and counted by check_convergence.

Note on standard errors (stochastic metafrontier): The stochastic metafrontier is a two-stage estimator. Stage 2 treats the fitted group frontier values as data, so the reported standard errors, confidence intervals, and variance-covariance matrix do not account for estimation uncertainty from Stage 1 (the generated-regressor problem; see Murphy and Topel, 1985). Use vcov(fit, correction = "murphy-topel") or bootstrap-based confidence intervals via boot_tgr for corrected inference.

Note on frontier orientation (SFA path): The SFA path estimates production frontiers (\varepsilon = v - u) by default and cost frontiers (\varepsilon = v + u) with frontier = "cost". For cost frontiers the deterministic metafrontier envelops the group cost frontiers from below, and TGR is the ratio of metatechnology to group minimum cost. The DEA path supports both orientation = "output" and orientation = "input".

Value

An object of class "metafrontier" (with subclass "metafrontier_sfa" or "metafrontier_dea"), containing:

call

the matched function call

group_models

list of fitted group-specific models

meta_coef

estimated metafrontier parameters

group_coef

list of group-specific coefficient vectors

tgr

technology gap ratios for each observation

te_group

group-specific technical efficiency

te_meta

metafrontier technical efficiency (TE* = TE x TGR)

logLik_groups

log-likelihoods of group models

nobs

number of observations per group and total

groups

group labels

method

estimation method used

meta_type

metafrontier type used

meta_convergence

integer convergence code for the metafrontier stage (0 = success; optim codes for the stochastic metafrontier and the QP barrier fallback, and 99 for a stochastic metafrontier whose log-likelihood is non-finite or impossibly large; 0 for a successful LP or DEA solution). Each SFA group model in group_models additionally carries its own convergence code. Use check_convergence to inspect all stages.

estimator, objective, engine, meta_solver

the estimation choices used for the fit

References

Battese, G.E., Rao, D.S.P. and O'Donnell, C.J. (2004). A metafrontier production function for estimation of technical efficiencies and technology gaps for firms operating under different technologies. Journal of Productivity Analysis, 21(1), 91–103. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1023/B:PROD.0000012454.06094.29")}

Huang, C.J., Huang, T.-H. and Liu, N.-H. (2014). A new approach to estimating the metafrontier production function based on a stochastic frontier framework. Journal of Productivity Analysis, 42(3), 241–254. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s11123-014-0402-2")}

O'Donnell, C.J., Rao, D.S.P. and Battese, G.E. (2008). Metafrontier frameworks for the study of firm-level efficiencies and technology ratios. Empirical Economics, 34(2), 231–255. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s00181-007-0119-4")}

Greene, W.H. (2010). A stochastic frontier model with correction for sample selection. Journal of Productivity Analysis, 34(1), 15–24. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s11123-009-0159-1")}

Glass, A.J., Kenjegalieva, K. and Sickles, R.C. (2016). A spatial autoregressive stochastic frontier model for panel data with asymmetric efficiency spillovers. Journal of Econometrics, 190(2), 289–300. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.jeconom.2015.06.011")}

LeSage, J. and Pace, R.K. (2009). Introduction to Spatial Econometrics. CRC Press.

Examples

# Simulate metafrontier data
set.seed(42)
sim <- simulate_metafrontier(n_groups = 2, n_per_group = 100)

# Estimate deterministic SFA metafrontier (BRO 2004)
fit <- metafrontier(log_y ~ log_x1 + log_x2,
                    data = sim$data,
                    group = "group",
                    method = "sfa",
                    meta_type = "deterministic")
summary(fit)

# Technology gap ratios
tgr <- technology_gap_ratio(fit)
summary(tgr)


metafrontier documentation built on Oct. 28, 2026, 5:13 p.m.