%\VignetteIndexEntry{Getting Started with sssvcqr} %\VignetteEngine{knitr::knitr} %\VignetteEncoding{UTF-8} \documentclass{article} \usepackage[margin=1in]{geometry} \usepackage{hyperref} \title{Getting Started with sssvcqr} \author{Houjian Hou} \begin{document} \maketitle This vignette shows the basic workflow for sparse-smooth spatially varying coefficient quantile regression. <>= knitr::opts_chunk$set(collapse = TRUE, comment = "#>") @ <>= library("sssvcqr") dat <- simulate_sssvcqr_data(n = 90, q = 1, p = 3, seed = 1) dat$active fit <- ss_svcqr( y = dat$y, Z = dat$Z, X = dat$X, u = dat$u, tau = 0.5, lambda1 = 5, lambda2 = 0.1, k_nn = 8, control = list(max_iter = 80, warn_nonconvergence = FALSE) ) fit summary(fit) selection_recovery_table(fit, dat) head(predict(fit)) head(predict(fit, type = "coefficients")) @ The spatial plot types use the first two columns of the coordinate matrix saved in the fitted object. Their colorbars show the numeric scale for deviations, local total coefficients, or residuals. <>= plot(fit, type = "deviation", index = 1) plot(fit, type = "coefficient", index = 1) plot(fit, type = "residual") @ Penalty parameters can be selected by spatially blocked cross-validation. The small grid below is for demonstration; empirical applications should use a broader grid and more iterations. <>= cv <- cv_ss_svcqr( y = dat$y, Z = dat$Z, X = dat$X, u = dat$u, tau = 0.5, lambda1_seq = c(1, 2), lambda2_seq = c(0.5, 1), K_folds = 3, adaptive_weights = FALSE, control = list(max_iter = 25, warn_nonconvergence = FALSE) ) cv cv$best @ \end{document}