cub_spline_est: Cubic spline fitting

View source: R/cub_spline_est.r

cub_spline_estR Documentation

Cubic spline fitting

Description

The function cub_spline_est is an implementation of the (un)constrained cubic spline estimates proposed by Daouia, Noh and Park (2016).

Usage

cub_spline_est(xtab, ytab, x, kn = ceiling((length(xtab))^(1/4)), method= "u",
               all.dea=FALSE, control = list("tm_limit" = 700))

Arguments

xtab

a numeric vector containing the observed inputs x_1,\ldots,x_n.

ytab

a numeric vector of the same length as xtab containing the observed outputs y_1,\ldots,y_n.

x

a numeric vector of evaluation points in which the estimator is to be computed.

kn

an integer specifying the number of inter-knot segments used in the computation of the spline estimate.

method

a character equal to "u" (unconstrained estimator), "m" (under the monotonicity constraint) or "mc" (under simultaneous monotonicity and concavity constraints).

all.dea

a boolean.

control

a list of parameters to the GLPK solver. See *Details* of help(Rglpk_solve_LP).

Details

Let a and b be, respectively, the minimum and maximum of the design points x_1,\ldots,x_n. Denote a partition of [a,b] by a=t_0<t_1<\cdots<t_{k_n}=b (see below the selection process). Let N=k_n+3 and \pi(x)=(\pi_0(x),\ldots,\pi_{N-1}(x))^T be the vector of normalized B-splines of order 4 based on the knot mesh \{t_j\} (see Daouia et al. (2015)). The unconstrained (option method="u") cubic spline estimate of the frontier \varphi(x) is then defined by \tilde\varphi_n(x)=\pi(x)^T \tilde\alpha, where \tilde\alpha minimizes

\int_{0}^1\pi(x)^T \alpha \,dx = \sum_{j=1}^N \alpha_j \int_{0}^1\pi_j(x) \,dx

over \alpha\in\R^N subject to the envelopment constraints \pi(x_i)^T \alpha\geq y_i, i=1,\ldots,n. A simple way of choosing the knot mesh in this unconstrained setting is by considering the j/k_nth quantiles t_j = x_{[j n/k_n]} of the distinct values of x_i for j=1,\ldots,k_n-1. The number of inter-knot segments k_n is obtained by calling the function cub_spline_kn (option method="u").

In what concerns the monotonicity constraint, we use the following suffcient condtion for the monotonicity:

\alpha_0 \leq \alpha_1 \leq \cdots \leq \alpha_{N-1}

. This condition was previously used in Lu et al. (2007) and Pya and Wood (2015). Note that since the condition corresponds to linear constraints on \alpha, the estimator satisfying the monotonocity can be obtained via linear programming.

When the estimate is required to be both monotone and concave, we use the function cub_spline_est with the option method="mc". Such estimate is obtained as the cubic spline function which minimizes the same linear objective function as the unconstrained estimate subject to the same linear envelopment constraints, the monotonicity constraint above and the additional linear concavity constraints \pi''(t_j)^T \alpha\leq , j=0,1,\ldots,k_n, where the second derivative \pi'' is a linear spline. Regarding the choice of knots, we just apply the same scheme as for the unconstrained cubic spline estimate.

Value

Returns a numeric vector with the same length as x. Returns a vector of NA if no solution has been found by the solver (GLPK).

Author(s)

Hohsuk Noh

References

Daouia, A., Noh, H. and Park, B.U. (2016). Data Envelope fitting with constrained polynomial splines. Journal of the Royal Statistical Society: Series B, 78(1), 3-30. doi:10.1111/rssb.12098.

Lu, M., Zhang, Y. and Huang, J. (2007). Estimation of the mean function with panel count data using monotone polynomial splines. Biometrika, 94, 705-718.

Pya, N. and Wood, S. N. (2015). Shape constrained additive models. Statistical Computing, to appear.

Schumaker, L.L. (2007). Spline Functions: Basic Theory, 3rd edition, Cambridge University Press.

See Also

cub_spline_kn

Examples

data("air")
x.air <- seq(min(air$xtab), max(air$xtab), length.out=101)
 
# 1. Unconstrained cubic spline fits
# Optimal number of inter-knot segments via the BIC criterion
(kn.bic.air.u<-cub_spline_kn(air$xtab, air$ytab, 
 method="u", type="BIC"))
# Unconstrained spline estimate
y.cub.air.u<-cub_spline_est(air$xtab, air$ytab, 
 x.air, kn=kn.bic.air.u, method="u")

# 2. Monotonicity constraint
# Optimal number of inter-knot segments via the BIC criterion
(kn.bic.air.m<-cub_spline_kn(air$xtab, air$ytab, 
 method="m", type="BIC")) 
# Monotonic splines estimate
y.cub.air.m<-cub_spline_est(air$xtab, air$ytab, 
 x.air, kn=kn.bic.air.m, method="m")
   
# 3. Monotonicity and Concavity constraints
# Optimal number of inter-knot segments via the BIC criterion
(kn.bic.air.mc<-cub_spline_kn(air$xtab, air$ytab, 
 method="mc", type="BIC"))
# Monotonic/Concave splines estimate 
y.cub.air.mc<-cub_spline_est(air$xtab, air$ytab, 
 x.air, kn=kn.bic.air.mc, method="mc", all.dea=TRUE)

# Representation 
plot(x.air, y.cub.air.u, lty=1, lwd=4, col="green", 
 type="l", xlab="log(COST)", ylab="log(OUTPUT)")   
lines(x.air, y.cub.air.m, lty=2, lwd=4, col="cyan")
lines(x.air, y.cub.air.mc, lty=3, lwd=4, col="magenta")   
points(ytab~xtab, data=air)
legend("topleft", col=c("green","cyan","magenta"), 
lty=c(1,2,3), legend=c("unconstrained", "monotone", 
 "monotone + concave"), lwd=4, cex=0.8)    

npbr documentation built on March 31, 2023, 7:45 p.m.