QRIndiv {QRegVCM} | R Documentation |
Individual quantile objective function
Description
The estimation of conditional quantile curves using individual quantile objective function.
Usage
QRIndiv(VecX, tau, times, subj, X, y, d, kn, degree, lambda, gam)
Arguments
VecX |
The representative values for each covariate used to estimate the desired conditional quantile curves. |
tau |
The quantiles of interest. |
times |
The vector of the time variable. |
subj |
The vector of subjects/individuals. |
X |
The covariate matrix containing 1 as its first column (including intercept in the model). |
y |
The response vector. |
d |
The order of the differencing operator for each covariate. |
kn |
The number of knots for each covariate. |
degree |
The degree of the B-spline basis function for each covariate. |
lambda |
The grid for the smoothing parameter to control the trade of between fidelity and penalty term (use a fine grid of lambda). |
gam |
The power used in estimating the smooting parameter for each covariate (e.g. gam=1 or gam=0.5). |
Value
alpha |
The estimator of the coefficient vector of the basis B-splines. |
hat_bt |
The varying coefficients estimators. |
qhat |
The conditional quantile curves estimator. |
Note
Some warning messages are related to the function rq.fit.sfn
.
Author(s)
Yudhie Andriyana
References
Andriyana, Y., Gijbels, I., and Verhasselt, A. P-splines quantile regression estimation in varying coefficient models. Test 23, 1 (2014a),153–194.
See Also
rq.fit.sfn
as.matrix.csr
truncSP
Examples
data(PM10)
PM10 = PM10[order(PM10$day,PM10$hour,decreasing=FALSE),]
y = PM10$PM10[1:200]
times = PM10$hour[1:200]
subj = PM10$day[1:200]
dim = length(y)
x0 = rep(1,200)
x1 = PM10$cars[1:200]
x2 = PM10$wind.speed[1:200]
X = cbind(x0, x1, x2)
VecX = c(1, max(x1), max(x2))
##########################
#### Input parameters ####
##########################
kn = c(10, 10, 10)
degree = c(3, 3, 3)
taus = seq(0.1,0.9,0.1)
lambdas = c(1,1.5,2)
d = c(1, 1, 1)
gam = 1/2
##########################
qhat = QRIndiv(VecX=VecX, tau=taus, times=times, subj=subj, X=X,
y=y, d=d, kn=kn, degree=degree, lambda=lambdas, gam=gam)$qhat
qhat1 = qhat[,1]
qhat2 = qhat[,2]
qhat3 = qhat[,3]
qhat4 = qhat[,4]
qhat5 = qhat[,5]
qhat6 = qhat[,6]
qhat7 = qhat[,7]
qhat8 = qhat[,8]
qhat9 = qhat[,9]
i = order(times, y, qhat1, qhat2, qhat3, qhat4, qhat5, qhat6, qhat7,
qhat8, qhat9);
times = times[i]; y = y[i]; qhat1 = qhat1[i]; qhat2=qhat2[i];
qhat3=qhat3[i]; qhat4=qhat4[i]; qhat5=qhat5[i]; qhat6=qhat6[i];
qhat7=qhat7[i]; qhat8=qhat8[i]; qhat9=qhat9[i];
ylim = range(qhat1, qhat9)
plot(qhat1~times, col="magenta", cex=0.2, lty=5, lwd=2, type="l",
ylim=ylim, xlab="hour", ylab="PM10");
lines(qhat2~times, col="aquamarine4", cex=0.2, lty=4, lwd=2);
lines(qhat3~times, col="blue", cex=0.2, lty=3, lwd=3);
lines(qhat4~times, col="brown", cex=0.2, lty=2, lwd=2);
lines(qhat5~times, col="black", cex=0.2, lty=1, lwd=2);
lines(qhat6~times, col="orange", cex=0.2, lty=2, lwd=2)
lines(qhat7~times, col="darkcyan", cex=0.2, lty=3, lwd=3);
lines(qhat8~times, col="green", cex=0.2, lty=4, lwd=2);
lines(qhat9~times, col="red", cex=0.2, lty=5, lwd=3)
legend("bottom", c(expression(tau==0.9), expression(tau==0.8),
expression(tau==0.7), expression(tau==0.6), expression(tau==0.5),
expression(tau==0.4), expression(tau==0.3), expression(tau==0.2),
expression(tau==0.1)), ncol=1, col=c("red","green","darkcyan",
"orange","black","brown","blue","aquamarine4","magenta"),
lwd=c(2,2,3,2,2,2,3,2,2), lty=c(5,4,3,2,1,2,3,4,5))