data("green")
plot(log(OUTPUT)~log(COST), data=green)
x <- seq(min(log(green$COST)), max(log(green$COST)), length.out=1001)
# under the separate monotonicity constraint with the knots mesh being
# obtained via AIC and BIC criteria
lines(x, quad_spline_est(log(green$COST), log(green$OUTPUT), x, kn=9, cv=0),
lty=1, col="red")
lines(x, quad_spline_est(log(green$COST), log(green$OUTPUT), x, kn=6, cv=0),
lty=1, col="blue")
# under both monotonicity and concavity constraints
# with the same optimal number of knots obtained using AIC and BIC criteria
lines(x, quad_spline_est(log(green$COST), log(green$OUTPUT), x, kn=1, cv=1),
lty=2)
legend("topleft",legend=c("monotonicity (kn=9)", "monotonicity (kn=6)",
"monotonicity + concavity (kn=1)"), col=c("red","blue","black"), lty=c(1,1,2))Run the code above in your browser using DataLab