# btf: Bayesian trend filtering via Eigen In btf: Estimates Univariate Function via Bayesian Trend Filtering

## Description

Fits Bayesian trend filtering hierarchical model to univariate function. Two conditional priors are available: double exponential or generalized double Pareto.

## Usage

 ```1 2 3``` ```btf(y = "vector", x = NULL, k = "int", iter = 10000, cond.prior = c("gdp", "dexp"), alpha = NULL, rho = NULL, D = "Matrix", m = 1, debug = FALSE) ```

## Arguments

 `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

## Author(s)

Edward A. Roualdes

## References

R. J. Tibshirani. Adaptive piecewise polynomial estimation via trend filtering. The Annals of Statistics, 42(1):285-323, 2014.

`trendfilter`
 ``` 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) ```