Learn R Programming

SPQR: Semi-Parametric Quantile Regression

The SPQR R package implements the semi-parametric quantile regression (SPQR) method in Xu and Reich (2021) [1]. It allows flexible modeling of the conditional distribution function and quantile function. The package provides three estimation procedures: maximum likelihood estimation (MLE) and maximum a posteriori (MAP) which are point estimates but computationally lighter, and Markov chain Monte Carlo (MCMC) which is fully Bayesian but computationally heavier. The MLE and MAP estimates are obtained using the Adam routine in torch, whereas the MCMC estimate is obtained using Stan-like Hamiltonian Monte Carlo (HMC) and no-U-turn sampler (NUTS).

Installation

You can install the development version of SPQR from GitHub with:

# install.packages("devtools")
devtools::install_github("stevengxu/SPQR")

Example

Estimate normal mixture distribution:

library(SPQR)
set.seed(919)
n <- 200
X <- rbinom(n, 1, 0.5)
Y <- rnorm(n, X, 0.8)
control <- list(iter = 300, warmup = 200, thin = 1)
fit <- SPQR(X = X, Y = Y, method = "MCMC", control = control, normalize = TRUE, verbose = FALSE)

## summarize output
print(fit, showModel = TRUE)
#> 
#> SPQR fitted using MCMC approach with ARD prior<U+0001F680>
#> 
#> Model specification:
#>     Layers
#>    Input Output Activation
#>        1     10       tanh
#>       10     10    softmax
#> 
#> MCMC diagnostics:
#>   Final acceptance ratio is 0.94 and target is 0.9
#> 
#> Expected log pointwise predictive density (elpd) estimates:
#>   elpd.LOO = 92.49707,  elpd.WAIC = 92.43618
#> 
#> Elapsed time: 0.25 minutes

## plot estimated PDF with 95% credible bands
plotEstimator(fit, type = "PDF", X = 0, ci.level = 0.95)

References

[1] Xu, S.G. and Reich, B.J., 2021. Bayesian nonparametric quantile process regression and estimation of marginal quantile effects. Biometrics.

Copy Link

Version

Install

install.packages('SPQR')

Monthly Downloads

12

Version

0.1.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

May 2nd, 2022

Functions in SPQR (0.1.0)

autoplot.SPQR

autoplot method for class SPQR
QALE

quantile accumulated local effects (ALE)
plotGOF

goodness-of-fit test for SPQR estimator
plotMCMCtrace

plot MCMC trace plots
load.SPQR

load saved SPQR model
createFolds.SPQR

generate cross-validation folds
SPQR

Fitting SPQR models
plotEstimator

plot SPQR estimators
coef.SPQR

coef method for class SPQR
save.SPQR

save fitted SPQR model
print.summary.SPQR

print method for "summary.SPQR"
plotQALE

plot accumulated local effects (ALE)
cv.SPQR

cross-validation for SPQR estimator
plotQVI

plot variable importance comparison by quantile
print.SPQR

print method for class SPQR
predict.SPQR

predict method for class SPQR
summary.SPQR

summary method for class SPQR
reexports

Objects exported from other packages