Description Usage Arguments Author(s) References See Also Examples
The function plot.amias
plots the coefficient from an "amias"
object with a user-specified number of knots as a function of the input positions (which are assumed to be evenly spaced if not specified). The function plot.samias
produces either a profile plot of the solution path for the primal variable or the optimal fitted coefficients (which, recall, are determined by minimizing the Bayesian Information Criterion) from a fitted "samias"
object.
1 2 3 4 |
x |
A list with class attribute 'amias' or 'samias'. |
add.knots |
Whether to add the locations of the detected knots at the top of the figure. It only works when |
type |
Types of the plotting figure, either "coef" or "vpath". For |
k |
The number of knots. Users can choose k from 1,2,…, kmax; if none are specified, then it plots the optimal coefficient determined by miniming the BIC value. |
add.label |
Whether to add labels at the right side to indicate the locations of the detected knots. It only works when |
... |
Other arguments,see |
Canhong Wen, Xueqin Wang, Shijie Quan, Zelin Hong and Aijun Zhang.
Maintainer: Canhong Wen <wench@ustc.edu.cn>
Wen, C., Zhu, J., Wang, X., and Zhang, A. (2019) L0 trend filtering, technique report.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ##----- A toy example of piecewise constant signal -------
set.seed(0)
n <- 100
x = seq(1/n, 1,length.out = n)
y0 = 0*x; y0[x>0.5] = 1
y = y0 + rnorm(n, sd = 0.1)
# For 'amias' object
fit <- amias(y, k = 1)
plot(fit)
# For 'samias' object
fit <- samias(y, kmax = 5)
plot(fit, type = "coef", main = "Piecewise Constant")
op <- par(mfrow=c(1,2))
plot(fit, type= "coef", add.knots = FALSE, main = "Piecewise Constant")
plot(fit, type = "vpath", main = "Piecewise Constant")
par(op)
##----- A toy example of piecewise linear trend -------
set.seed(0)
y0 = 2*(0.5-x); y0[x>0.5] = 2*(x[x>0.5]-0.5)
y = y0 + rnorm(n, sd = 0.1)
# For 'amias' object
fit <- amias(y, D_type = "tfq", q = 1, k = 1)
plot(fit, main = "Piecewise Linear")
# For 'samias' object
fit <- samias(y, D_type = "tfq", q = 1, kmax = 4)
op <- par(mfrow=c(1,2))
plot(fit, type = "coef", main = "Piecewise Linear")
plot(fit, type = "vpath", main = "Piecewise Linear")
par(op)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.