Package 'copulaSQM'

Title: Copula Based Stochastic Frontier Quantile Model
Description: Estimation of a copula-based stochastic frontier quantile model using simulated likelihood methods.
Authors: Dr. Woraphon Yamaka
Maintainer: Dr. Woraphon Yamaka <[email protected]>
License: GPL-3
Version: 0.1.0
Built: 2026-06-03 09:53:18 UTC
Source: https://github.com/woraphonyamaka/copulasqm

Help Index


Copula-Based Stochastic Frontier Quantile Model

Description

Estimates a copula-based stochastic frontier quantile model using simulated maximum likelihood. Dependence between the two-sided noise component and the one-sided inefficiency component is captured via a bivariate copula from the VineCopula package.

Usage

copSQM(Y, X, family, tau,
       RHO, LB, UB,
       RHO2 = NULL, LB2 = NULL, UB2 = NULL,
       nSim = 50,
       seed = NULL,
       maxit = 10000)

Arguments

Y

A numeric vector of dependent variable observations.

X

A numeric matrix (or object coercible to a matrix) of explanatory variables. The intercept is added internally.

family

Integer specifying the bivariate copula family (see VineCopula::BiCopPDF). Examples include 1 = Gaussian, 2 = Student-t. Some copula families require a second parameter.

tau

Quantile level in (0,1)(0,1) for the asymmetric Laplace distribution (ALD).

RHO

Initial value of the first copula parameter (passed to par in VineCopula). Note that this parameter is not always a correlation; its interpretation depends on the chosen copula family.

LB

Lower bound for the first copula parameter RHO.

UB

Upper bound for the first copula parameter RHO.

RHO2

Optional initial value of the second copula parameter (passed to par2 in VineCopula). This is required for copula families that have two parameters (e.g. Student-t where RHO2 represents degrees of freedom, and BB families where RHO2 is a shape parameter). If NULL, a one-parameter copula is assumed.

LB2

Optional lower bound for the second copula parameter RHO2. Must be supplied when RHO2 is not NULL.

UB2

Optional upper bound for the second copula parameter RHO2. Must be supplied when RHO2 is not NULL.

nSim

Number of Monte Carlo draws used to approximate the likelihood integral for each observation. Larger values improve accuracy but increase computation time.

seed

Optional integer seed for reproducibility of the simulation draws used in the likelihood. If NULL, no seed is set.

maxit

Maximum number of iterations for the optimizer (stats::optim with "L-BFGS-B").

Details

The model follows the stochastic frontier decomposition

Yi=xiβ+viui,Y_i = x_i^\top \beta + v_i - u_i,

where viv_i is a two-sided noise term and ui0u_i \ge 0 is the inefficiency term. Both components are modeled using the asymmetric Laplace distribution (ALD) at quantile level tau, with uiu_i truncated to (0,)(0,\infty).

Dependence between uiu_i and viv_i is introduced through a bivariate copula density c(,)c(\cdot,\cdot) from the VineCopula package. The log-likelihood is evaluated by simulating draws of uiu_i from the truncated ALD and approximating the likelihood integral by Monte Carlo averaging (nSim draws per observation).

When a two-parameter copula family is used, RHO2 must be provided along with bounds LB2 and UB2.

Value

A list with components:

result

A matrix of parameter estimates, standard errors, z-values, and p-values.

AIC

Akaike Information Criterion.

BIC

Bayesian Information Criterion.

Loglikelihood

Maximized log-likelihood value.

convergence

Convergence code returned by stats::optim. A value of 0 indicates successful convergence.

Author(s)

Woraphon Yamaka, Paravee Maneejuk and Nuttaphong Kaewtathip

References

Pipitpojanakarn, V., Maneejuk, P., Yamaka, W., & Sriboonchitta, S. (2016). Analysis of agricultural production in Asia and measurement of technical efficiency using copula-based stochastic frontier quantile model. In International Symposium on Integrated Uncertainty in Knowledge Modelling and Decision Making (pp. 701–714). Springer.

Pipitpojanakarn, V., Yamaka, W., Sriboonchitta, S., & Maneejuk, P. (2017). Frontier Quantile Model Using a Generalized Class of Skewed Distributions. Advanced Science Letters, 23(11), 10737–10742.

Examples

set.seed(123)

sim_data <- sfa_simu_quantile(
  n = 50,
  beta = c(1, 0.5, -0.3),
  sigV = 1,
  sigU = 1,
  tau = 0.5,
  family = 1,
  rho = 0.3,
  seed = 123
)

model <- copSQM(
  Y = sim_data$Y,
  X = sim_data$X,
  family = 1,
  tau = 0.5,
  RHO = 0.3,
  LB = -0.99,
  UB = 0.99,
  nSim = 50,
  seed = 123
)
model

## Example with a two-parameter copula (e.g., Student-t: family = 2)
## Here RHO2 typically represents degrees of freedom and must be bounded.
model_t <- copSQM(
  Y = sim_data$Y,
  X = sim_data$X,
  family = 2,
  tau = 0.5,
  RHO = 0.3,
  LB = -0.99,
  UB = 0.99,
  RHO2 = 4,
  LB2 = 2.01,
  UB2 = 50,
  nSim = 50,
  seed = 123
)
model_t

Simulation of Copula-Based Stochastic Frontier Quantile Model

Description

Generates simulated data from a copula-based stochastic frontier quantile model with asymmetric Laplace noise and a truncated asymmetric Laplace inefficiency term.

Usage

sfa_simu_quantile(n,
                  beta,
                  sigV,
                  sigU,
                  tau = 0.5,
                  family = 1,
                  rho = 0.5,
                  rho2 = NULL,
                  seed = NULL)

Arguments

n

Integer. Number of observations to simulate.

beta

Numeric vector of regression coefficients including an intercept. Its length must match the number of regressors plus one (intercept). This simulator generates two regressors, so length(beta) must be 3.

sigV

Positive numeric value. Scale parameter of the two-sided noise term VV.

sigU

Positive numeric value. Scale parameter of the one-sided inefficiency term UU.

tau

Quantile level in (0,1)(0,1). Default is 0.5.

family

Integer specifying the bivariate copula family (see VineCopula::BiCopSim). Examples include 1 (Gaussian) and 2 (Student-t). Some families require a second parameter rho2.

rho

First copula parameter (passed to par in VineCopula). Interpretation depends on the copula family and is not always a correlation.

rho2

Optional second copula parameter (passed to par2 in VineCopula). This must be provided for copula families that require a second parameter (e.g., degrees of freedom for the Student-t copula, or a shape parameter for BB copulas).

seed

Optional integer seed for reproducibility. If NULL, no seed is set.

Details

This function simulates data from the stochastic frontier model:

Y=Xβ+VU,Y = X\beta + V - U,

where:

  • VV follows an asymmetric Laplace distribution (ALD) with location 00, scale sigV, and quantile level tau.

  • UU is a non-negative inefficiency term generated from an ALD distribution with location 00, scale sigU, and quantile level tau, truncated to (0,)(0,\infty).

  • Dependence between VV and UU is introduced via a bivariate copula using VineCopula::BiCopSim.

The simulator constructs two regressors internally (denoted x1x_1 and x2x_2).

Value

A list containing:

Y

Numeric vector of simulated dependent variable values.

X

Matrix of simulated independent variables (without intercept column).

V

Simulated two-sided noise term.

U

Simulated non-negative inefficiency term.

copula_uniforms

The simulated dependent uniforms from the copula (two columns).

Author(s)

Woraphon Yamaka, Paravee Maneejuk and Nuttaphong Kaewtathip

References

Koenker, R. (2005). Quantile Regression. Cambridge University Press.

Joe, H. (2014). Dependence Modeling with Copulas. Chapman & Hall/CRC.

Examples

sim_data <- sfa_simu_quantile(
  n = 100,
  beta = c(1, 0.5, -0.3),
  sigV = 1,
  sigU = 1,
  tau = 0.5,
  family = 1,
  rho = 0.3,
  seed = 123
)
str(sim_data)

Technical Efficiency Measure

Description

Computes technical efficiency for a copula-based stochastic frontier quantile model using simulation-based conditional expectations.

Usage

TE(theta, Y, X, family, tau,
   nSim = 200,
   rho2 = NULL,
   seed = NULL,
   plot = FALSE)

Arguments

theta

Numeric vector of estimated model parameters. The expected ordering is: regression coefficients (including intercept), σv\sigma_v, σu\sigma_u, copula parameter rho, and optionally rho2 if a two-parameter copula is used.

Y

Numeric vector of dependent variable observations.

X

Numeric matrix (or object coercible to a matrix) of independent variables (without intercept column).

family

Integer specifying the copula family (see VineCopula::BiCopPDF). Some families require a second parameter rho2.

tau

Quantile level in (0,1)(0,1) for the asymmetric Laplace distribution.

nSim

Number of Monte Carlo draws used to approximate the conditional expectation. Larger values reduce simulation noise but increase computation time.

rho2

Optional second copula parameter. If NULL and theta contains an additional element beyond rho, the function will use that element as rho2.

seed

Optional integer seed for reproducibility in simulation-based computation. If NULL, no seed is set.

plot

Logical. If TRUE, produces a plot of sorted technical efficiency values.

Details

Technical efficiency is computed as a simulated conditional expectation:

TEi=E[exp(Ui)wi],TE_i = E[\exp(-U_i) \mid w_i],

where wi=Yixiβw_i = Y_i - x_i^\top\beta and the weights are constructed using the asymmetric Laplace density for the noise term and the copula density capturing dependence between the inefficiency component and the noise component.

The inefficiency term UU is generated from a truncated asymmetric Laplace distribution on (0,)(0,\infty).

If plot = TRUE, the function produces a line plot of sorted technical efficiency values.

Value

A numeric vector of technical efficiency values (one per observation).

Author(s)

Woraphon Yamaka, Paravee Maneejuk, and Nuttaphong Kaewtathip

References

Pipitpojanakarn, V., Maneejuk, P., Yamaka, W., & Sriboonchitta, S. (2016). Analysis of agricultural production in Asia and measurement of technical efficiency using copula-based stochastic frontier quantile model. In International Symposium on Integrated Uncertainty in Knowledge Modelling and Decision Making (pp. 701–714). Springer.

Examples

sim_data <- sfa_simu_quantile(
  n = 100,
  beta = c(1, 0.5, -0.3),
  sigV = 1,
  sigU = 1,
  tau = 0.5,
  family = 1,
  rho = 0.3,
  seed = 123
)

model <- copSQM(
  Y = sim_data$Y,
  X = sim_data$X,
  family = 1,
  tau = 0.5,
  RHO = 0.3,
  LB = -0.99,
  UB = 0.99,
  nSim = 50,
  seed = 123
)

te_values <- TE(
  theta = model$result[, "Estimate"],
  Y = sim_data$Y,
  X = sim_data$X,
  family = 1,
  tau = 0.5,
  nSim = 200,
  seed = 123,
  plot = TRUE
)

head(te_values)