Description Usage Arguments Details Value References Examples
Fits conditional mean of data with kernel smoothing, imposing monotonicity and/or concavity constraints.
1 2 |
X.eval |
Matrix of inputs used for fitting |
y.eval |
Vector of outputs used for fitting |
X.constrained |
Matrix of inputs where constraints apply |
X.fit |
Matrix of inputs where curve is fit; defaults to X.constrained |
H.inv |
Inverse of the smoothing matrix (must be positive definite); defaults to rule of thumb |
H.mult |
Scaling factor for rule of thumb smoothing matrix |
method |
Constraints to apply; "u" for unconstrained, "m" for monotonically increasing, and "mc" for monotonically increasing and concave |
scale.constraints |
Boolean, whether to scale constraints by their average value, can help with convergence |
This method uses kernel smoothing to fit the mean of the data while imposing specified monotonicity and concavity constraints. The procedure is derived from Racine et al. (2009), which develops kernel smoothing methods with bounding, monotonicity and concavity constraints. Specifically, the smoothing procedure involves finding optimal weights for a Nadaraya-Watson estimator of the form
\hat{y} = m(x) = ∑_{i=1}^N p_i A(x, x_i) y_i,
where x are inputs, y are outputs, p are weights, subscripts index observations, and
A(x, x_i) = \frac{K(x, x_i)}{∑_{h=1}^N K(x, x_h)}
for a kernel K. This method uses a multivariate normal kernel of the form
K(x, x_h) = \exp≤ft(-\frac12 (x - x_h)'H^{-1}(x - x_h)\right),
where H is a bandwidth matrix. Bandwidth selection is performed via Silverman's
(1986) rule-of-thumb, in the function H.inv.select
.
Optimal weights \hat{p} are selected by solving the quadratic programming problem
\min_p \mbox{\ \ }-\mathbf{1}'p + \frac12 p'p.
Monotonicity constraints of the following form can be imposed at specified points:
\frac{\partial m(x)}{\partial x^j} = ∑_{h=1}^N p_h \frac{\partial A(x, x_h)}{\partial x^j} y_h ≥q 0 \mbox{\ \ \ \ }\forall x, j,
where superscripts index inputs. Finally concavity constraints of the following form can also be imposed using Afriat's (1967) conditions:
m(x) - m(z) ≤q \nabla_x m(z) \cdot (x - z) \mbox{\ \ \ \ }\forall x, z.
The gradient of the estimated curve at a point x is given by
\nabla_x m(x) = ∑_{i=1}^N \hat{p}_i \nabla_x A(x, x_i) y_i,
where \hat{p}_i are estimated weights.
Returns a list with the following elements
y.fit |
Estimated value of the frontier at X.fit |
gradient.fit |
Estimated gradient of the frontier at X.fit |
solution |
Boolean; TRUE if frontier successfully estimated |
X.eval |
Matrix of inputs used for fitting |
X.constrained |
Matrix of inputs where constraints apply |
X.fit |
Matrix of inputs where curve is fit |
H.inv |
Inverse smoothing matrix used in fitting |
method |
Method used to fit frontier |
scaling.factor |
Factor by which constraints are multiplied before quadratic programming |
ParmeterRacinesnfa
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | data(USMacro)
USMacro <- USMacro[complete.cases(USMacro),]
# Extract data
X <- as.matrix(USMacro[,c("K", "L")])
y <- USMacro$Y
# Reflect data for fitting
reflected.data <- reflect.data(X, y)
X.eval <- reflected.data$X
y.eval <- reflected.data$y
# Fit frontier
fit.mc <- fit.mean(X.eval, y.eval,
X.constrained = X,
X.fit = X,
method = "mc")
# Plot input productivities over time
library(ggplot2)
plot.df <- data.frame(Year = rep(USMacro$Year, times = 2),
Elasticity = c(fit.mc$gradient.fit[,1] * X[,1] / y,
fit.mc$gradient.fit[,2] * X[,2] / y),
Variable = rep(c("Capital", "Labor"), each = nrow(USMacro)))
ggplot(plot.df, aes(Year, Elasticity)) +
geom_line() +
facet_grid(Variable ~ ., scales = "free_y")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.