| softthresh | R Documentation |
This function computes solution path to a fused lasso problem of the form
1/2 ∑_{i=1}^n (y_i - β_i)^2 + λ ∑_{(i,j) \in E} |β_i - β_j| + γ \cdot λ ∑_{i=1}^p |β_i|,
given the solution path corresponding to γ=0. Note that the predictor matrix here is the identity, and in this case the new solution path is given by a simple soft-thresholding operation (Friedman et al. 2007).
softthresh(object, lambda, gamma)
object |
an object of class "fusedlasso", fit with no predictor matrix
|
lambda |
a numeric vector giving the values of lambda at which the solution
should be computed and returned; if missing, defaults to the knots
in the solution path stored in |
gamma |
a numeric variable giving the ratio of the fusion and sparsity tuning parameters, must be greater than or equal to 0. |
Returns a numeric matrix of primal solutions, one column for each value of lambda.
Friedman J., Hastie T., Hoefling H. and Tibshirani, R. (2007), "Pathwise coordinate optimization", Annals of Applied Statistics 1 (2) 302–332.
fusedlasso
# The 1d fused lasso
set.seed(0)
n = 100
beta0 = rep(sample(1:10,5),each=n/5)
beta0 = beta0-mean(beta0)
y = beta0 + rnorm(n,sd=0.8)
a = fusedlasso1d(y)
lambda = 4
b1 = coef(a,lambda=lambda)$beta
gamma = 0.5
b2 = softthresh(a,lambda=lambda,gamma=gamma)
plot(1:n,y)
lines(1:n,b1)
lines(1:n,b2,col="red")
legend("topright",lty=1,col=c("black","red"),
legend=c(expression(gamma==0),expression(gamma==0.5)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.