# simul_shapetest: Testing the shape of a functional coefficient in the median... In QRegVCM: Quantile Regression in Varying-Coefficient Models

## Description

Testing a functional coefficient of a covariate in the median and/or the variability function, considering the general hetersocedastic varying-coefficient model in Gijbels etal (2017a).

Y(t)=∑_{k=0}^{p}β_{k}(t)X^{(k)}(t)+γ(t)\exp(∑_{k=1}^{p}θ_{k}(t)X^{(k)}(t))ε(t).

## Usage

 ```1 2``` ```simul_shapetest(times, subj, X, y, d, kn, degree, lambda, gam, v, nr.bootstrap.samples, seed, test,omega) ```

## Arguments

 `times` The vector of time variable. `subj` The vector of subject indicator. `X` The covariates, containing 1 as its first component (including intercept in the model). `y` The response vector. `d` The order of differencing operator for each covariate. `kn` The number of knot intervals for each covariate. `degree` The degree of B-spline basis for each covariate. `lambda` The grid of smoothing parameter to control the trade 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). `v` The covariate indicator for which the shape test is interested. `nr.bootstrap.samples` The number of bootstrap samples used. `seed` The seed for the random generator in the bootstrap resampling. `test` The requested type of testing, it consists two arguments: the first argument for median and the second for the variability function. "c" stands for constancy, "m" stands for monotonicity, and "conv" stands for convexity. insert NA to the other argument when only for median/ variability function is needed.. `omega` A user defined constraint parameter for monotonicity or convexity (in Equation (7) of Gijbels etal (2017a)), chosen as large as possible.

## Value

 `result` The testing procedures. `P` The p-values. `GR` The test statistics for the given data. `Gb` The bootstrap test statistics.

## Note

Some warning messages are related to the function `rq.fit.sfn`.

## Author(s)

Mohammed Abdulkerim Ibrahim

## References

Andriyana, Y. and Gijbels, I. & Verhasselt, A. (2014). P-splines quantile regression estimation in varying coefficient models. Test, 23, 153-194.

Andriyana, Y., Gijbels, I. and Verhasselt, A. (2017). Quantile regression in varying-coefficient models: non-crossing quantile curves and heteroscedasticity. Statistical Papers, DOI:10.1007/s00362-016-0847-7

Gijbels, I., Ibrahim, M. A., and Verhasselt, A. (2017a). Shape testing in quantile varying coefficient models with heteroscedastic error. Journal of Nonparametric Statistics, 29(2):391-406.

Gijbels, I., Ibrahim, M. A., and Verhasselt, A. (2017b). Testing the heteroscedastic error structure in quantile varying coefficient models. The Canadian Journal of Statistics, DOI:10.1002/cjs.11346.

He, X. (1997). Quantile curves without crossing. The American Statistician, 51, 186-192.

`rq.fit.sfn` `as.matrix.csr` `truncSP`
 ``` 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 31 32 33 34 35 36 37``` ```data(wages) y = wages\$resp ## the hourly wage times = wages\$exper ## the duration of work experience in years subj = wages\$id ## subject indicator (individual) dim=length(y) ## number of rows in the data = 6402 x0 = rep(1,dim) ## for intercept ### the covariates ## creating 2 dummy variables for the race covariate wages\$r1[wages\$race=="black"]=1 wages\$r1[wages\$race!="black"]=0 wages\$r2[wages\$race=="hisp"]=1 wages\$r2[wages\$race!="hisp"]=0 x1 = wages\$r1 # stands for black x2 = wages\$r2 # stands for hispanic x3 = wages\$hgc ## the highest grade completed by the indiviadual X = cbind(x0, x1, x2, x3) ## the covariate matrix px=ncol(X) ########################## ### Input parameters #### ######################### lambda = 1 # we used 10^seq(-2, 1, 0.1) in Gijbels etal (2017a) kn = rep(1,px) # used rep(5,px) in Gijbels etal (2017a) degree = rep(2,px) # the degree of splines d = rep(1,px) gam=0.25 nr.bootstrap.samples=2 # used 200 in Gijbels etal (2017a) seed=110 ######################### test1=simul_shapetest(times=times, subj=subj, X=X, y=y, d=d, kn=kn, degree=degree, lambda=lambda, gam=gam, v=1, nr.bootstrap.samples=nr.bootstrap.samples,seed=seed, test=c("c",NA),omega=10^3) #### Testing results test1\$result #the testing procedures test1\$P ## p-values test1\$R ## test statistics ```