Description Usage Arguments Author(s) References See Also Examples
Fits Bayesian trend filtering hierarchical model to univariate function. Two conditional priors are available: double exponential or generalized double Pareto.
| 1 2 3 | 
| y | response vector | 
| x | inputs corresponding to y observations | 
| k | degree of polynomial fit | 
| iter | number of samples to draw from posterior | 
| cond.prior | choose the conditional prior on f|sigma | 
| alpha | shape parameter for prior on lambda | 
| rho | rate parameter for prior on lambda | 
| D | linear transformation of coefficients inside penalty | 
| m | sample f every mth iteration, default is m=1 | 
| debug | boolean telling btf to check for NaNs or not | 
Edward A. Roualdes
R. J. Tibshirani. Adaptive piecewise polynomial estimation via trend filtering. The Annals of Statistics, 42(1):285-323, 2014.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # Cubic trend filtering
# from genlasso::trendfilter
## Not run: 
n <- 100
beta0 = numeric(100)
beta0[1:40] <- (1:40-20)^3
beta0[40:50] <- -60*(40:50-50)^2 + 60*100+20^3
beta0[50:70] <- -20*(50:70-50)^2 + 60*100+20^3
beta0[70:100] <- -1/6*(70:100-110)^3 + -1/6*40^3 + 6000
beta0 <- -beta0
beta0 <- (beta0-min(beta0))*10/diff(range(beta0))
y <- beta0 + rnorm(n)
bfit <- btf(y=y, k=3)
plot(bfit, col='grey70')
## End(Not run)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.