Learn R Programming

sfa (version 1.2.0)

pcomposed: The distribution of the composed error

Description

Density and distribution function of the stochastic frontier composed error \(\varepsilon = v - u\) (production) or \(v + u\) (cost), with \(v \sim N(0, \sigma_v^2)\) and \(u \sim N^+(0, \sigma_u^2)\) independent. The density is a skew-normal and closed form; the distribution function is not, and is obtained here by quadrature that stays accurate far into the tails.

Usage

dcomposed(x, sigma_u, sigma_v, inefdec = TRUE, log = FALSE)

pcomposed(q, sigma_u, sigma_v, inefdec = TRUE, lower.tail = TRUE, log.p = FALSE, method = c("quadrature", "simulate"), n_nodes = 128, R = 1e6, seed = NULL)

Value

A numeric vector the length of x or q.

Arguments

x, q

Numeric vector of quantiles.

sigma_u

Standard deviation of the pre-truncation normal behind \(u\). Zero is allowed and is the no-inefficiency boundary, where the composed error is just the noise.

sigma_v

Standard deviation of the noise, strictly positive.

inefdec

TRUE (the default) for a production frontier, \(\varepsilon = v - u\); FALSE for a cost frontier, \(\varepsilon = v + u\). The two are mirror images.

log, log.p

Return the log of the density or probability. Use log.p = TRUE whenever the result may be extremely small.

lower.tail

If TRUE (the default) probabilities are \(P(\varepsilon \le q)\), otherwise \(P(\varepsilon > q)\). The upper tail is computed directly rather than as \(1 - F\); see ‘Details’.

method

"quadrature" (the default) is deterministic Gauss-Legendre. "simulate" is the estimator of Amsler, Schmidt and Tsay (2019), kept for comparison.

n_nodes

Quadrature nodes, at least 16.

R, seed

Draws and optional seed for method = "simulate". The seed is restored afterwards, so the caller's random stream is untouched.

Details

Why this exists. Every likelihood in sfa evaluates the composed error's density and none needs its distribution function, which is why there was not one. Copula models need it: a Gaussian copula on the composed error contains \(\Phi^{-1}(F(\varepsilon))\), so an \(F\) that saturates at 0 or 1 does not merely lose precision, it returns an infinity and takes the copula density with it.

How it is computed. Conditioning on \(u\) leaves a normal distribution function in closed form, so $$F(q) = E_u\left[\Phi\left((q + su)/\sigma_v\right)\right],$$ with \(s = +1\) for a production frontier and \(-1\) for a cost frontier. The noise is therefore never drawn or integrated, and the tails inherit the accuracy of pnorm, which is reliable twenty standard deviations out. The expectation over \(u\) is taken by Gauss-Legendre quadrature on \(u = \sigma_u t/(1-t)\), and accumulated by log-sum-exp so that terms which would underflow individually still contribute.

The upper tail. Requesting lower.tail = FALSE negates the argument of \(\Phi\) rather than forming \(1 - F\). At \(q = 30\) with \(\sigma_u = \sigma_v = 1\) the complement is exactly 1 in double precision while the direct computation returns a finite log-probability below \(-10^{2}\).

Accuracy. There is no closed form except at \(\lambda = \sigma_u/\sigma_v\) equal to 0 (the normal) or 1, where Amsler, Schmidt and Tsay show \(P(Q) = \Phi(Q/(\sqrt{2}\sigma_u))^2\) for the cost case. Against that standard the default quadrature is accurate to about \(10^{-13}\) relative at probabilities as small as \(10^{-115}\). It is deliberately used everywhere rather than special-cased at \(\lambda = 1\): the production form of that identity is a complement, which would reintroduce the saturation the function exists to avoid.

References

Amsler, C., Schmidt, P. and Tsay, W.-J. (2019). Evaluating the cdf of the distribution of the stochastic frontier composed error. Journal of Productivity Analysis, 52(1), 29--35.

See Also

copsfm, sfm

Examples

Run this code
## Density integrates to one.
integrate(function(x) dcomposed(x, 1, 0.5), -Inf, Inf)$value

## Distribution function, and a tail that does not saturate.
pcomposed(c(-2, 0, 2), sigma_u = 1, sigma_v = 0.5)
pcomposed(30, 1, 1, lower.tail = FALSE, log.p = TRUE)

## Checked against the one exact standard there is (cost frontier).
su <- sv <- sqrt(0.5)
c(exact = pnorm(-6 / (sqrt(2) * su))^2,
  computed = exp(pcomposed(-6, su, sv, inefdec = FALSE, log.p = TRUE)))

Run the code above in your browser using DataLab