plot.amias: Plotting method for amias and samias objects

Description Usage Arguments Author(s) References See Also Examples

Description

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.

Usage

1
2
3
4
## S3 method for class 'amias'
plot(x, add.knots = TRUE,...)
## S3 method for class 'samias'
plot(x, type = c("coef", "vpath"), k, add.label = TRUE, add.knots = TRUE,...)

Arguments

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 = "coef" for the function plot.samias.

type

Types of the plotting figure, either "coef" or "vpath". For type = "coef" and missing k, we plot the optimal l_0 fitted coefficients as well as the raw data. For type = "coef" and a user-specified k, we plot the l_0 fitted coefficients with number of knots k as well as the raw data. For type = "vpath", we plot the solution path of the primal variable v versus the cardinality k, i.e., number of the detected knots.

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 type = "vpath" for the function plot.samias.

...

Other arguments,see plot.default for details.

Author(s)

Canhong Wen, Xueqin Wang, Shijie Quan, Zelin Hong and Aijun Zhang.

Maintainer: Canhong Wen <wench@ustc.edu.cn>

References

Wen, C., Zhu, J., Wang, X., and Zhang, A. (2019) L0 trend filtering, technique report.

See Also

amias, samias.

Examples

 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)
  

AMIAS documentation built on May 2, 2019, 2:10 a.m.

Related to plot.amias in AMIAS...