metafrontier

Analysis of Metafrontier Models for Efficiency and Productivity

Overview

metafrontier provides a unified R implementation of metafrontier production function models for estimating technical efficiencies and technology gaps across groups of firms that face different restrictions of a common underlying metatechnology (group-specific technologies in the sense of Battese, Rao & O’Donnell, 2004).

Estimation methods

Productivity analysis

Inference and diagnostics

Visualisation

Interoperability

Installation

Install the development version from GitHub:

# install.packages("devtools")
devtools::install_github("iik1/metafrontier")

Quick start

library(metafrontier)

# Simulate metafrontier data with two technology groups
sim <- simulate_metafrontier(n_groups = 2, n_per_group = 200, seed = 42)

# Estimate a deterministic SFA-based metafrontier
fit_det <- metafrontier(log_y ~ log_x1 + log_x2,
                        data = sim$data, group = "group")

# Estimate a stochastic metafrontier (with Murphy-Topel SEs)
fit_sto <- metafrontier(log_y ~ log_x1 + log_x2,
                        data = sim$data, group = "group",
                        meta_type = "stochastic")

# DEA-based metafrontier (requires level-scale inputs/outputs)
dat_lev <- within(sim$data, { y <- exp(log_y); x1 <- exp(log_x1); x2 <- exp(log_x2) })
fit_dea <- metafrontier(y ~ x1 + x2,
                        data = dat_lev, group = "group",
                        method = "dea", rts = "vrs")

# Inspect results
summary(fit_det)
tgr_summary(fit_det)
confint(fit_det)

Bootstrap confidence intervals

boot <- boot_tgr(fit_det, R = 999, seed = 1)
confint(boot)

# Parallel bootstrap
boot_par <- boot_tgr(fit_det, R = 999, ncores = 4, seed = 1)

Malmquist productivity index

# Simulate panel data
panel <- simulate_panel_metafrontier(n_groups = 3, n_firms_per_group = 50,
                                     n_periods = 5, seed = 42)

# Three-way Malmquist decomposition
malm <- malmquist_meta(log_y ~ log_x1 + log_x2,
                       data = panel$data, group = "group",
                       time = "year")
summary(malm)

Latent class metafrontier

# Automatic class selection via BIC (discovers groups endogenously)
lc <- latent_class_metafrontier(log_y ~ log_x1 + log_x2,
                                data = sim$data,
                                n_classes = 3)
summary(lc)

Visualisation

# Base R
plot(fit_det, which = "tgr")
plot(fit_det, which = "decomposition")

# ggplot2
library(ggplot2)
autoplot(fit_det)
autoplot(boot)
autoplot(malm)

Using pre-fitted models

library(sfaR)

# Fit group-specific SFA models externally
sfa_g1 <- sfacross(log_y ~ log_x1 + log_x2,
                   data = subset(sim$data, group == "G1"))
sfa_g2 <- sfacross(log_y ~ log_x1 + log_x2,
                   data = subset(sim$data, group == "G2"))

# Pass to metafrontier
fit <- metafrontier(models = list(G1 = sfa_g1, G2 = sfa_g2))

Vignettes

The package includes three vignettes:

browseVignettes("metafrontier")

References

License

GPL (>= 3)