Learn R Programming

spacejam (version 1.1)

plot.SJ:

plot an object of class SJ or SJ.dag

Description

This function plots an SJ or SJ.dag

Usage

"plot"(x, which = NULL, layout = NULL, ...)

Arguments

x

an object of class SJ or SJ.dag

which

The index of which to plot. If not specified, the penalty with the smallest BIC is used.

layout

the layout of the graph to use. If not specified, layout.fruchterman.reingold is used.

...
additional parameters to be passed to plot.igraph.

Value

returns the layout used, invisibly.

Details

This function plots a graph in SJ or SJ.dags 'graph' field, using some sane degaults for vertex size and color.

References

Voorman, Shojaie and Witten (2013). Graph Estimation with Joint Additive Models. Submitted to Biometrika. available on ArXiv or from authors upon request

See Also

plot.igraph spacejam SJ generate.dag.data

Examples

Run this code
p <- 100 #variables
n <- 50 #observations

#Generate Data
set.seed(20)
g <- rdag(p,80)
data <- generate.dag.data(g,n,basesd=c(1,0.5,0.5))
X <- data$X

#Fit conditional independence graph for sequence of 10 lambdas
fit1 <- SJ(X, length = 10)

par(mfrow=c(1,2))
layout <- plot(fit1, main = "min BIC")
plot(fit1, which=5, layout = layout, main = paste0("lambda = ",round(fit1$lambda[5],3)))

Run the code above in your browser using DataLab