Package 'spefa'

Title: Spatial Stochastic Frontier with Fixed Effects and Endogeneity
Description: Maximum-likelihood estimation of the spatial autoregressive stochastic frontier model with individual fixed effects (removed by first differencing) and endogenous regressors handled through a Gaussian control function, as in Giannini (2025) <doi:10.1080/17421772.2024.2414962>. Returns coefficient estimates and standard errors, spatially-corrected technical (in)efficiency scores, and direct, indirect and total marginal impacts. Depends only on base R.
Authors: Massimo Giannini [aut, cre] (University of Rome Tor Vergata, Department of Enterprise Engineering)
Maintainer: Massimo Giannini <[email protected]>
License: GPL-3
Version: 0.1.0
Built: 2026-05-29 08:10:46 UTC
Source: https://github.com/cran/spefa

Help Index


Technical (in)efficiency scores

Description

Conditional-mean (JLMS) inefficiency estimates with optional spatial rescaling by (IλW)1(I-\lambda W)^{-1}.

Usage

efficiency(object, spatial = TRUE)

Arguments

object

a fitted spefa object.

spatial

logical; apply the spatial multiplier.

Value

A list with the inefficiency matrix u (N x T), efficiency eff = exp(-u), and per-unit Eu_i.

Examples

data(spefademo)
fit <- spefa(y ~ x1 + q1, data = spefademo, index = c("id", "time"),
             W = spefaW, endogenous = list(q1 = ~ z1, q2 = ~ z2),
             scaling = ~ x2 + q2)
ef <- efficiency(fit)
summary(as.vector(ef$eff))

Direct, indirect and total marginal impacts (with inference)

Description

LeSage-Pace decomposition of frontier marginal effects through the spatial multiplier (IλW)1(I-\lambda W)^{-1}. Standard errors, z-statistics and p-values are obtained by simulation from the asymptotic distribution of (β,λ)(\beta,\lambda).

Usage

impacts(object, ...)

## S3 method for class 'spefa'
impacts(object, R = 1000, seed = NULL, ...)

Arguments

object

a fitted spefa object.

R

number of simulation draws for the standard errors.

seed

optional integer seed for reproducibility.

...

unused.

Value

An object of class impacts.spefa: a list with matrices Direct, Indirect and Total, each with columns Estimate, Std.Error, z value and Pr(>|z|).

Examples

data(spefademo)
fit <- spefa(y ~ x1 + q1, data = spefademo, index = c("id", "time"),
             W = spefaW, endogenous = list(q1 = ~ z1, q2 = ~ z2),
             scaling = ~ x2 + q2)
impacts(fit, R = 500, seed = 1)

Spatial Stochastic Frontier with Fixed Effects and Endogeneity

Description

Maximum-likelihood estimation of a spatial autoregressive stochastic frontier model with individual fixed effects (removed by first differencing) and endogenous regressors handled by a Gaussian control function.

Usage

spefa(formula, data, index, W, endogenous = NULL, scaling = NULL,
      mu = FALSE, control = list(maxit = 500, reltol = 1e-9))

Arguments

formula

frontier equation, e.g. y ~ x1 + q1. The intercept is removed by first differencing.

data

a balanced panel data.frame.

index

length-2 character vector c(unit, time).

W

an N x N spatial weight matrix, rows/cols ordered by sorted unit id.

endogenous

named list mapping endogenous regressors to instruments, e.g. list(q1 = ~ z1, q2 = ~ z2), or NULL.

scaling

one-sided formula of variables entering the inefficiency scaling hit=exp(zitϕ)h_{it}=\exp(z_{it}'\phi), e.g. ~ x2 + q2.

mu

logical; if TRUE estimate the truncation point (truncated-normal inefficiency), else half-normal.

control

list passed to optim.

Value

An object of class spefa with methods summary, coef, vcov, logLik, efficiency and impacts.

Examples

data(spefademo)
fit <- spefa(y ~ x1 + q1, data = spefademo, index = c("id", "time"),
             W = spefaW, endogenous = list(q1 = ~ z1, q2 = ~ z2),
             scaling = ~ x2 + q2)
summary(fit)

Simulated demo panel for spefa

Description

A small simulated balanced panel and its spatial weight matrix, used in the examples and vignette. Generated from the model in Giannini (2025) with β=(0.5,0.5)\beta=(0.5,0.5), δ=(1,1)\delta=(1,1), ϕ=(0.3,0.3)\phi=(0.3,0.3), σε2=0.09\sigma^2_\varepsilon=0.09, σv2=0.04\sigma^2_v=0.04, ρ=(0.5,0.5)\rho=(0.5,0.5), σu2=0.09\sigma^2_u=0.09 and λ=0.5\lambda=0.5; q1 and q2 are endogenous, q1 enters the frontier and q2 the scaling.

Usage

data(spefademo)

Format

spefademo: a data.frame with 480 rows (N = 40 units, T = 12 periods) and columns id, time, y, x1, x2, q1, q2, z1, z2.

spefaW: a 40 x 40 row-normalised spatial weight matrix, ordered by id.

Examples

data(spefademo)
str(spefademo)
dim(spefaW)