knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
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).
You can install the development version of SPQR from GitHub with:
# install.packages("devtools") devtools::install_github("stevengxu/SPQR")
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) ## plot estimated PDF with 95% credible bands plotEstimator(fit, type = "PDF", X = 0, ci.level = 0.95)
[1] Xu, S.G. and Reich, B.J., 2021. Bayesian nonparametric quantile process regression and estimation of marginal quantile effects. Biometrics.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.