Skip to content

Plotting

Simone Vazzoler edited this page Apr 24, 2017 · 1 revision

Plotting a generic matrix

To plot a generic matrix, use the function

plotMatrix(M, colors="dark")

where M is the matrix you want to plot and colors="dark" is the color-scale that is used (colors can be "light" or "dark").

Example

Let us generate and plot a random 10x10 matrix

M <- matrix(rnorm(100), ncol=10, nrow=10)
plotMatrix(M)

plot1

To plot the same matrix with a light color scale use

plotMatrix(M, colors="light")

plot2

Plotting a VAR object

It is possible to plot directly a VAR object (fitted or simulated) using the function

plotVAR(..., colors = "dark")

Example

Now we simulate a VAR(2) process and then we estimate it using "ENET" and "SCAD":

sim <- simulateVAR(N = 15, p = 2, sparsity = 0.15, covariance = "block2")
fitENET <- fitVAR(sim$series, p = 2, foldsIDs = TRUE)
fitSCAD <- fitVAR(sim$series, p = 2, penalty = "SCAD", foldsIDs = TRUE)

and then we plot all the models

plotVAR(sim, fitENET, fitSCAD, colors = "light")

plot3

Clone this wiki locally