Last updated on 2020-02-19 10:49:10 CET.
Flavor | Version | Tinstall | Tcheck | Ttotal | Status | Flags |
---|---|---|---|---|---|---|
r-devel-linux-x86_64-debian-clang | 1.1 | 8.82 | 66.95 | 75.77 | ERROR | |
r-devel-linux-x86_64-debian-gcc | 1.1 | 7.13 | 49.29 | 56.42 | ERROR | |
r-devel-linux-x86_64-fedora-clang | 1.1 | 90.46 | ERROR | |||
r-devel-linux-x86_64-fedora-gcc | 1.1 | 87.73 | ERROR | |||
r-devel-windows-ix86+x86_64 | 1.1 | 16.00 | 139.00 | 155.00 | NOTE | |
r-devel-windows-ix86+x86_64-gcc8 | 1.1 | 23.00 | 140.00 | 163.00 | NOTE | |
r-patched-linux-x86_64 | 1.1 | 8.36 | 77.38 | 85.74 | NOTE | |
r-patched-solaris-x86 | 1.1 | 212.10 | NOTE | |||
r-release-linux-x86_64 | 1.1 | 8.27 | 77.37 | 85.64 | NOTE | |
r-release-windows-ix86+x86_64 | 1.1 | 16.00 | 134.00 | 150.00 | NOTE | |
r-release-osx-x86_64 | 1.1 | NOTE | ||||
r-oldrel-windows-ix86+x86_64 | 1.1 | 10.00 | 127.00 | 137.00 | NOTE | |
r-oldrel-osx-x86_64 | 1.1 | NOTE |
Version: 1.1
Check: DESCRIPTION meta-information
Result: NOTE
Malformed Title field: should not end in a period.
Flavors: r-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc, r-devel-linux-x86_64-fedora-clang, r-devel-linux-x86_64-fedora-gcc, r-devel-windows-ix86+x86_64, r-devel-windows-ix86+x86_64-gcc8, r-patched-linux-x86_64, r-patched-solaris-x86, r-release-linux-x86_64, r-release-windows-ix86+x86_64, r-release-osx-x86_64, r-oldrel-windows-ix86+x86_64, r-oldrel-osx-x86_64
Version: 1.1
Check: dependencies in R code
Result: NOTE
'library' or 'require' call to 'Matrix' which was already attached by Depends.
Please remove these calls from your code.
Packages in Depends field not imported from:
'Matrix' 'igraph' 'splines'
These packages need to be imported from (in the NAMESPACE file)
for when this namespace is loaded but not attached.
Flavors: r-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc, r-devel-linux-x86_64-fedora-clang, r-devel-linux-x86_64-fedora-gcc, r-devel-windows-ix86+x86_64, r-devel-windows-ix86+x86_64-gcc8, r-patched-linux-x86_64, r-patched-solaris-x86, r-release-linux-x86_64, r-release-windows-ix86+x86_64, r-release-osx-x86_64, r-oldrel-windows-ix86+x86_64, r-oldrel-osx-x86_64
Version: 1.1
Check: R code for possible problems
Result: NOTE
SJ: no visible binding for global variable 'bs'
SJ: no visible global function definition for 'get.adjacency'
SJ : <anonymous>: no visible global function definition for
'graph.adjacency'
SJ: no visible binding for global variable 'ecount'
SJ.dag: no visible binding for global variable 'bs'
SJ.dag : <anonymous>: no visible global function definition for
'graph.adjacency'
SJ.dag: no visible binding for global variable 'ecount'
SJpath: no visible global function definition for 'get.adjacency'
SJpath : <anonymous>: no visible global function definition for
'graph.adjacency'
generate.dag.data: no visible global function definition for 'vcount'
generate.dag.data: no visible global function definition for
'topological.sort'
generate.dag.data: no visible global function definition for
'neighbors'
generate.dag.data: no visible global function definition for 'rnorm'
generate.dag.data: no visible global function definition for 'runif'
grpsel: no visible global function definition for 'Matrix'
moralize: no visible global function definition for 'vcount'
moralize: no visible global function definition for 'as.undirected'
moralize: no visible global function definition for 'get.adjacency'
moralize: no visible global function definition for 'add.edges'
moralize: no visible global function definition for 'combn'
moralize: no visible global function definition for 'simplify'
plot.SJ: no visible global function definition for
'layout.fruchterman.reingold'
plot.SJ: no visible global function definition for 'plot'
plot.SJ.dag: no visible global function definition for
'layout.fruchterman.reingold'
plot.SJ.dag: no visible global function definition for 'plot'
print.SJ: no visible binding for global variable 'ecount'
print.SJ: no visible global function definition for 'ecount'
print.SJ.dag: no visible binding for global variable 'ecount'
print.SJ.dag: no visible global function definition for 'ecount'
rdag: no visible global function definition for 'graph.adjacency'
Undefined global functions or variables:
Matrix add.edges as.undirected bs combn ecount get.adjacency
graph.adjacency layout.fruchterman.reingold neighbors plot rnorm
runif simplify topological.sort vcount
Consider adding
importFrom("graphics", "plot")
importFrom("stats", "rnorm", "runif")
importFrom("utils", "combn")
to your NAMESPACE file.
Flavors: r-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc, r-devel-linux-x86_64-fedora-clang, r-devel-linux-x86_64-fedora-gcc, r-devel-windows-ix86+x86_64, r-devel-windows-ix86+x86_64-gcc8, r-patched-linux-x86_64, r-patched-solaris-x86, r-release-linux-x86_64, r-release-windows-ix86+x86_64, r-release-osx-x86_64, r-oldrel-windows-ix86+x86_64, r-oldrel-osx-x86_64
Version: 1.1
Check: Rd line widths
Result: NOTE
Rd file 'SJ.Rd':
\examples lines wider than 100 characters:
#with standard deviations of 1, 0.5 and 0.5, (i.e. giving more weight to linear association than quadratic or cubic)
#Fit conditional independence graph at one lambda , using the default basis functions (cubic polynomials).
plot(g, layout=mylayout, edge.color = "gray50", vertex.color = "red", vertex.size = 3, vertex.label = NA, edge.arrow.size = 0.4, main=" ... [TRUNCATED]
Rd file 'generate.dag.data.Rd':
\examples lines wider than 100 characters:
#with standard deviations of 1, 0.5 and 0.5, (i.e. giving more weight to linear association than quadratic or cubic)
Rd file 'spacejam-package.Rd':
\examples lines wider than 100 characters:
#with standard deviations of 1, 0.5 and 0.5, (i.e. giving more weight to linear association than quadratic or cubic)
plot(g, layout=mylayout, edge.color = "gray50", vertex.color = "red", vertex.size = 3, vertex.label = NA, edge.arrow.size = 0.4, main=" ... [TRUNCATED]
These lines will be truncated in the PDF manual.
Flavors: r-devel-linux-x86_64-debian-clang, r-devel-linux-x86_64-debian-gcc, r-devel-linux-x86_64-fedora-clang, r-devel-linux-x86_64-fedora-gcc
Version: 1.1
Check: examples
Result: ERROR
Running examples in 'spacejam-Ex.R' failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: SJ
> ### Title: Estimate a graph with Spacejam
> ### Aliases: SJ SJ.dag
> ### Keywords: graphs optimize
>
> ### ** Examples
>
> #########Create graph and distribution used in Figure 2 of Voorman, Shojaie and Witten (2013):
> p <- 100 #variables
> n <- 50 #observations
>
> #Generate Graph
> set.seed(20)
> g <- rdag(p,80)
> mylayout <- layout.fruchterman.reingold(g)
>
> par(mfrow=c(1,2))
> plot(g, layout = mylayout, edge.color = "gray50",
+ vertex.color = "red", vertex.size = 3, vertex.label = NA,
+ edge.arrow.size = 0.4)
> plot(moralize(g), layout = mylayout, edge.color = "gray50",
+ vertex.color = "red", vertex.size = 3, vertex.label = NA,
+ edge.arrow.size = 0.4)
>
> #create a distribution on the DAG using cubic polynomials with random normal coefficients
> #with standard deviations of 1, 0.5 and 0.5, (i.e. giving more weight to linear association than quadratic or cubic)
> data <- generate.dag.data(g,n,basesd=c(1,0.5,0.5))
> X <- data$X
>
> #Fit conditional independence graph at one lambda , using the default basis functions (cubic polynomials).
> fit1 <- SJ(X, lambda = 0.6)
>
> #Fit conditional independence graph at 10 (hopefully reasonable) lambdas:
> fit2 <- SJ(X, length = 10)
>
> #Fit conditional independence graph using quadratic basis functions:
> fit3 <- SJ(X, bfun = function(x){cbind(x,x^2)}, length = 10)
>
> #Fit the DAG using default causal ordering 1:p, and at 10 lambdas
> fit4 <- SJ.dag(X, length = 10)
> fit4
Object of class "SJ.dag"
Contains the graphs:
lambda Edges bic
1 0.800 0 19459.10
2 0.740 9 19477.89
3 0.670 24 19493.19
4 0.600 43 19481.95
5 0.530 61 19432.97
6 0.450 109 19426.46
7 0.360 231 19648.50
8 0.270 542 20645.94
9 0.160 1134 23135.28
10 0.046 2358 27793.09
Call:
SJ.dag(X = X, length = 10)
>
> #plot the DAGs, and the true graph
> par(mfrow=c(1,3))
> plot(g, layout=mylayout, edge.color = "gray50", vertex.color = "red", vertex.size = 3, vertex.label = NA, edge.arrow.size = 0.4, main="True DAG")
> plot(fit4, layout = mylayout, which= 4, main= paste0("lambda = ",round(fit4$lambda[4],2) ))
> plot(fit4, layout = mylayout, main = "min BIC")
>
> ###For additional replications using the same DAG distribution use e.g.
> data <- generate.dag.data(g,n,funclist = data$funclist)
>
>
> #### Screen out edges whose corresponding nodes have low spearman correlation:
> # useful for approximating spacejam in high dimesnions
> S <- cor(data$X, method = "spearman")
> G.max <- S > 0.1
> mean(G.max) #~75% of edges removed
[1] 0.2458
>
> system.time({fit.screen <- SJ(X, G.max = G.max,length=20)})
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
spacejam
--- call from context ---
SJ(X, G.max = G.max, length = 20)
--- call from argument ---
if (class(G.max) == "igraph") G.max <- get.adjacency(G.max, sparse = TRUE) ==
1
--- R stacktrace ---
where 1: SJ(X, G.max = G.max, length = 20)
where 2: system.time({
fit.screen <- SJ(X, G.max = G.max, length = 20)
})
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (X, bfun = bs, lambda = NULL, length = NULL, verbose = FALSE,
b0 = NULL, maxit = 100, tol = .Machine$double.eps^0.25, G.max = NULL)
{
cl <- match.call()
bfun <- match.fun(bfun)
n <- nrow(X)
p <- ncol(X)
k <- ncol(bfun(X[, 1]))
if (!is.null(b0) & any(dim(b0) != c(n, p * k))) {
stop("dimensions of b0 not compatible with basis function")
}
if (!is.null(G.max)) {
if (class(G.max) == "igraph")
G.max <- get.adjacency(G.max, sparse = TRUE) == 1
stopifnot(storage.mode(G.max) == "logical")
stopifnot(ncol(X) == ncol(G.max))
}
if (!is.null(lambda) & !is.null(length)) {
if (length(lambda) != length)
warning("Lambda and length not compatible. Using lambda")
}
if (is.null(lambda) & is.null(length))
length = 10
if (!is.null(lambda) & any(lambda < 0))
stop("lambda must be positive")
X <- apply(X, 2, scale)
bigX <- matrix(NA, nrow = k * p, ncol = n)
for (j in 1:p) {
bigX[p * (1:k - 1) + j, ] <- t(svd(apply(bfun(X[, j]),
2, scale, scale = F))$u * sqrt(n - 1))
}
if (is.null(lambda)) {
M <- matrix(NA, nrow = p, ncol = p)
tmp <- bigX %*% X/(n - 1)
for (i in 1:p) {
for (j in (1:p)[-i]) {
M[i, j] <- sum(tmp[p * (1:k - 1) + j, i]^2)
}
}
M <- sqrt(M + t(M))
lmin <- sort(c(M))[p]
lmax <- max(M, na.rm = T)
lambda <- rev(log(seq(exp(lmin), exp(lmax), length = length)))
}
if (verbose)
cat("Progress: \n")
dfs <- rss <- matrix(0, p, length(lambda))
adjmat <- array(dim = c(p, p, length(lambda)))
for (i in 1:length(lambda)) {
out <- grpsel(X = X, bigX = bigX, lambda = lambda[i],
n = n, k = k, p = p, tol = tol, maxit = maxit, b0 = b0,
G.max = G.max)
b0 = out$b0
adjmat[, , i] <- out$G
tmp <- rowsum(t(out$betas^2) * (n - 1), rep(1:p, k))
dfs[, i] <- colSums(out$G) + (k - 1) * rowSums((tmp)/(tmp +
lambda[i]))
rss[, i] <- colSums((X - t(out$betas %*% bigX))^2)
if (verbose)
cat(".")
}
class(out) <- "SJ"
out$X = X
out$graph <- apply(adjmat, 3, function(GG) {
graph.adjacency(GG, mode = "undirected")
})
out$cl <- cl
out$bigX = bigX
out$n = n
out$k = k
out$p = p
out$tol = tol
out$maxit = maxit
out$verbose = verbose
out$G.max = G.max
out$lambda = lambda
out$G = adjmat
out$dfs = dfs
out$rss = rss
out$ecount <- unlist(lapply(out$graph, ecount))
out$bic = colSums(n * log(rss) + dfs * log(n))
return(out)
}
<bytecode: 0xc2cad88>
<environment: namespace:spacejam>
--- function search by body ---
Function SJ in namespace spacejam has this body.
----------- END OF FAILURE REPORT --------------
Error in if (class(G.max) == "igraph") G.max <- get.adjacency(G.max, sparse = TRUE) == :
the condition has length > 1
Calls: system.time -> SJ
Timing stopped at: 1.228 0.084 1.337
Execution halted
Flavor: r-devel-linux-x86_64-debian-clang
Version: 1.1
Check: examples
Result: ERROR
Running examples in ‘spacejam-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: SJ
> ### Title: Estimate a graph with Spacejam
> ### Aliases: SJ SJ.dag
> ### Keywords: graphs optimize
>
> ### ** Examples
>
> #########Create graph and distribution used in Figure 2 of Voorman, Shojaie and Witten (2013):
> p <- 100 #variables
> n <- 50 #observations
>
> #Generate Graph
> set.seed(20)
> g <- rdag(p,80)
> mylayout <- layout.fruchterman.reingold(g)
>
> par(mfrow=c(1,2))
> plot(g, layout = mylayout, edge.color = "gray50",
+ vertex.color = "red", vertex.size = 3, vertex.label = NA,
+ edge.arrow.size = 0.4)
> plot(moralize(g), layout = mylayout, edge.color = "gray50",
+ vertex.color = "red", vertex.size = 3, vertex.label = NA,
+ edge.arrow.size = 0.4)
>
> #create a distribution on the DAG using cubic polynomials with random normal coefficients
> #with standard deviations of 1, 0.5 and 0.5, (i.e. giving more weight to linear association than quadratic or cubic)
> data <- generate.dag.data(g,n,basesd=c(1,0.5,0.5))
> X <- data$X
>
> #Fit conditional independence graph at one lambda , using the default basis functions (cubic polynomials).
> fit1 <- SJ(X, lambda = 0.6)
>
> #Fit conditional independence graph at 10 (hopefully reasonable) lambdas:
> fit2 <- SJ(X, length = 10)
>
> #Fit conditional independence graph using quadratic basis functions:
> fit3 <- SJ(X, bfun = function(x){cbind(x,x^2)}, length = 10)
>
> #Fit the DAG using default causal ordering 1:p, and at 10 lambdas
> fit4 <- SJ.dag(X, length = 10)
> fit4
Object of class "SJ.dag"
Contains the graphs:
lambda Edges bic
1 0.800 0 19459.10
2 0.740 9 19477.89
3 0.670 24 19493.19
4 0.600 43 19481.95
5 0.530 61 19432.97
6 0.450 109 19426.46
7 0.360 231 19648.50
8 0.270 542 20645.94
9 0.160 1134 23135.28
10 0.046 2358 27793.09
Call:
SJ.dag(X = X, length = 10)
>
> #plot the DAGs, and the true graph
> par(mfrow=c(1,3))
> plot(g, layout=mylayout, edge.color = "gray50", vertex.color = "red", vertex.size = 3, vertex.label = NA, edge.arrow.size = 0.4, main="True DAG")
> plot(fit4, layout = mylayout, which= 4, main= paste0("lambda = ",round(fit4$lambda[4],2) ))
> plot(fit4, layout = mylayout, main = "min BIC")
>
> ###For additional replications using the same DAG distribution use e.g.
> data <- generate.dag.data(g,n,funclist = data$funclist)
>
>
> #### Screen out edges whose corresponding nodes have low spearman correlation:
> # useful for approximating spacejam in high dimesnions
> S <- cor(data$X, method = "spearman")
> G.max <- S > 0.1
> mean(G.max) #~75% of edges removed
[1] 0.2458
>
> system.time({fit.screen <- SJ(X, G.max = G.max,length=20)})
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
spacejam
--- call from context ---
SJ(X, G.max = G.max, length = 20)
--- call from argument ---
if (class(G.max) == "igraph") G.max <- get.adjacency(G.max, sparse = TRUE) ==
1
--- R stacktrace ---
where 1: SJ(X, G.max = G.max, length = 20)
where 2: system.time({
fit.screen <- SJ(X, G.max = G.max, length = 20)
})
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (X, bfun = bs, lambda = NULL, length = NULL, verbose = FALSE,
b0 = NULL, maxit = 100, tol = .Machine$double.eps^0.25, G.max = NULL)
{
cl <- match.call()
bfun <- match.fun(bfun)
n <- nrow(X)
p <- ncol(X)
k <- ncol(bfun(X[, 1]))
if (!is.null(b0) & any(dim(b0) != c(n, p * k))) {
stop("dimensions of b0 not compatible with basis function")
}
if (!is.null(G.max)) {
if (class(G.max) == "igraph")
G.max <- get.adjacency(G.max, sparse = TRUE) == 1
stopifnot(storage.mode(G.max) == "logical")
stopifnot(ncol(X) == ncol(G.max))
}
if (!is.null(lambda) & !is.null(length)) {
if (length(lambda) != length)
warning("Lambda and length not compatible. Using lambda")
}
if (is.null(lambda) & is.null(length))
length = 10
if (!is.null(lambda) & any(lambda < 0))
stop("lambda must be positive")
X <- apply(X, 2, scale)
bigX <- matrix(NA, nrow = k * p, ncol = n)
for (j in 1:p) {
bigX[p * (1:k - 1) + j, ] <- t(svd(apply(bfun(X[, j]),
2, scale, scale = F))$u * sqrt(n - 1))
}
if (is.null(lambda)) {
M <- matrix(NA, nrow = p, ncol = p)
tmp <- bigX %*% X/(n - 1)
for (i in 1:p) {
for (j in (1:p)[-i]) {
M[i, j] <- sum(tmp[p * (1:k - 1) + j, i]^2)
}
}
M <- sqrt(M + t(M))
lmin <- sort(c(M))[p]
lmax <- max(M, na.rm = T)
lambda <- rev(log(seq(exp(lmin), exp(lmax), length = length)))
}
if (verbose)
cat("Progress: \n")
dfs <- rss <- matrix(0, p, length(lambda))
adjmat <- array(dim = c(p, p, length(lambda)))
for (i in 1:length(lambda)) {
out <- grpsel(X = X, bigX = bigX, lambda = lambda[i],
n = n, k = k, p = p, tol = tol, maxit = maxit, b0 = b0,
G.max = G.max)
b0 = out$b0
adjmat[, , i] <- out$G
tmp <- rowsum(t(out$betas^2) * (n - 1), rep(1:p, k))
dfs[, i] <- colSums(out$G) + (k - 1) * rowSums((tmp)/(tmp +
lambda[i]))
rss[, i] <- colSums((X - t(out$betas %*% bigX))^2)
if (verbose)
cat(".")
}
class(out) <- "SJ"
out$X = X
out$graph <- apply(adjmat, 3, function(GG) {
graph.adjacency(GG, mode = "undirected")
})
out$cl <- cl
out$bigX = bigX
out$n = n
out$k = k
out$p = p
out$tol = tol
out$maxit = maxit
out$verbose = verbose
out$G.max = G.max
out$lambda = lambda
out$G = adjmat
out$dfs = dfs
out$rss = rss
out$ecount <- unlist(lapply(out$graph, ecount))
out$bic = colSums(n * log(rss) + dfs * log(n))
return(out)
}
<bytecode: 0x558a059ef650>
<environment: namespace:spacejam>
--- function search by body ---
Function SJ in namespace spacejam has this body.
----------- END OF FAILURE REPORT --------------
Error in if (class(G.max) == "igraph") G.max <- get.adjacency(G.max, sparse = TRUE) == :
the condition has length > 1
Calls: system.time -> SJ
Timing stopped at: 1.056 0.044 1.927
Execution halted
Flavor: r-devel-linux-x86_64-debian-gcc
Version: 1.1
Check: compiled code
Result: NOTE
File ‘spacejam/libs/spacejam.so’:
Found no calls to: ‘R_registerRoutines’, ‘R_useDynamicSymbols’
It is good practice to register native routines and to disable symbol
search.
See ‘Writing portable packages’ in the ‘Writing R Extensions’ manual.
Flavors: r-devel-linux-x86_64-fedora-clang, r-devel-linux-x86_64-fedora-gcc
Version: 1.1
Check: examples
Result: ERROR
Running examples in ‘spacejam-Ex.R’ failed
The error most likely occurred in:
> ### Name: SJ
> ### Title: Estimate a graph with Spacejam
> ### Aliases: SJ SJ.dag
> ### Keywords: graphs optimize
>
> ### ** Examples
>
> #########Create graph and distribution used in Figure 2 of Voorman, Shojaie and Witten (2013):
> p <- 100 #variables
> n <- 50 #observations
>
> #Generate Graph
> set.seed(20)
> g <- rdag(p,80)
> mylayout <- layout.fruchterman.reingold(g)
>
> par(mfrow=c(1,2))
> plot(g, layout = mylayout, edge.color = "gray50",
+ vertex.color = "red", vertex.size = 3, vertex.label = NA,
+ edge.arrow.size = 0.4)
> plot(moralize(g), layout = mylayout, edge.color = "gray50",
+ vertex.color = "red", vertex.size = 3, vertex.label = NA,
+ edge.arrow.size = 0.4)
>
> #create a distribution on the DAG using cubic polynomials with random normal coefficients
> #with standard deviations of 1, 0.5 and 0.5, (i.e. giving more weight to linear association than quadratic or cubic)
> data <- generate.dag.data(g,n,basesd=c(1,0.5,0.5))
> X <- data$X
>
> #Fit conditional independence graph at one lambda , using the default basis functions (cubic polynomials).
> fit1 <- SJ(X, lambda = 0.6)
>
> #Fit conditional independence graph at 10 (hopefully reasonable) lambdas:
> fit2 <- SJ(X, length = 10)
>
> #Fit conditional independence graph using quadratic basis functions:
> fit3 <- SJ(X, bfun = function(x){cbind(x,x^2)}, length = 10)
>
> #Fit the DAG using default causal ordering 1:p, and at 10 lambdas
> fit4 <- SJ.dag(X, length = 10)
> fit4
Object of class "SJ.dag"
Contains the graphs:
lambda Edges bic
1 0.800 0 19459.10
2 0.740 9 19477.89
3 0.670 24 19493.19
4 0.600 43 19481.95
5 0.530 61 19432.97
6 0.450 109 19426.46
7 0.360 231 19648.50
8 0.270 542 20645.94
9 0.160 1134 23135.28
10 0.046 2358 27793.09
Call:
SJ.dag(X = X, length = 10)
>
> #plot the DAGs, and the true graph
> par(mfrow=c(1,3))
> plot(g, layout=mylayout, edge.color = "gray50", vertex.color = "red", vertex.size = 3, vertex.label = NA, edge.arrow.size = 0.4, main="True DAG")
> plot(fit4, layout = mylayout, which= 4, main= paste0("lambda = ",round(fit4$lambda[4],2) ))
> plot(fit4, layout = mylayout, main = "min BIC")
>
> ###For additional replications using the same DAG distribution use e.g.
> data <- generate.dag.data(g,n,funclist = data$funclist)
>
>
> #### Screen out edges whose corresponding nodes have low spearman correlation:
> # useful for approximating spacejam in high dimesnions
> S <- cor(data$X, method = "spearman")
> G.max <- S > 0.1
> mean(G.max) #~75% of edges removed
[1] 0.2458
>
> system.time({fit.screen <- SJ(X, G.max = G.max,length=20)})
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
spacejam
--- call from context ---
SJ(X, G.max = G.max, length = 20)
--- call from argument ---
if (class(G.max) == "igraph") G.max <- get.adjacency(G.max, sparse = TRUE) ==
1
--- R stacktrace ---
where 1: SJ(X, G.max = G.max, length = 20)
where 2: system.time({
fit.screen <- SJ(X, G.max = G.max, length = 20)
})
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (X, bfun = bs, lambda = NULL, length = NULL, verbose = FALSE,
b0 = NULL, maxit = 100, tol = .Machine$double.eps^0.25, G.max = NULL)
{
cl <- match.call()
bfun <- match.fun(bfun)
n <- nrow(X)
p <- ncol(X)
k <- ncol(bfun(X[, 1]))
if (!is.null(b0) & any(dim(b0) != c(n, p * k))) {
stop("dimensions of b0 not compatible with basis function")
}
if (!is.null(G.max)) {
if (class(G.max) == "igraph")
G.max <- get.adjacency(G.max, sparse = TRUE) == 1
stopifnot(storage.mode(G.max) == "logical")
stopifnot(ncol(X) == ncol(G.max))
}
if (!is.null(lambda) & !is.null(length)) {
if (length(lambda) != length)
warning("Lambda and length not compatible. Using lambda")
}
if (is.null(lambda) & is.null(length))
length = 10
if (!is.null(lambda) & any(lambda < 0))
stop("lambda must be positive")
X <- apply(X, 2, scale)
bigX <- matrix(NA, nrow = k * p, ncol = n)
for (j in 1:p) {
bigX[p * (1:k - 1) + j, ] <- t(svd(apply(bfun(X[, j]),
2, scale, scale = F))$u * sqrt(n - 1))
}
if (is.null(lambda)) {
M <- matrix(NA, nrow = p, ncol = p)
tmp <- bigX %*% X/(n - 1)
for (i in 1:p) {
for (j in (1:p)[-i]) {
M[i, j] <- sum(tmp[p * (1:k - 1) + j, i]^2)
}
}
M <- sqrt(M + t(M))
lmin <- sort(c(M))[p]
lmax <- max(M, na.rm = T)
lambda <- rev(log(seq(exp(lmin), exp(lmax), length = length)))
}
if (verbose)
cat("Progress: \n")
dfs <- rss <- matrix(0, p, length(lambda))
adjmat <- array(dim = c(p, p, length(lambda)))
for (i in 1:length(lambda)) {
out <- grpsel(X = X, bigX = bigX, lambda = lambda[i],
n = n, k = k, p = p, tol = tol, maxit = maxit, b0 = b0,
G.max = G.max)
b0 = out$b0
adjmat[, , i] <- out$G
tmp <- rowsum(t(out$betas^2) * (n - 1), rep(1:p, k))
dfs[, i] <- colSums(out$G) + (k - 1) * rowSums((tmp)/(tmp +
lambda[i]))
rss[, i] <- colSums((X - t(out$betas %*% bigX))^2)
if (verbose)
cat(".")
}
class(out) <- "SJ"
out$X = X
out$graph <- apply(adjmat, 3, function(GG) {
graph.adjacency(GG, mode = "undirected")
})
out$cl <- cl
out$bigX = bigX
out$n = n
out$k = k
out$p = p
out$tol = tol
out$maxit = maxit
out$verbose = verbose
out$G.max = G.max
out$lambda = lambda
out$G = adjmat
out$dfs = dfs
out$rss = rss
out$ecount <- unlist(lapply(out$graph, ecount))
out$bic = colSums(n * log(rss) + dfs * log(n))
return(out)
}
<bytecode: 0xb148160>
<environment: namespace:spacejam>
--- function search by body ---
Function SJ in namespace spacejam has this body.
----------- END OF FAILURE REPORT --------------
Error in if (class(G.max) == "igraph") G.max <- get.adjacency(G.max, sparse = TRUE) == :
the condition has length > 1
Calls: system.time -> SJ
Timing stopped at: 1.495 0.105 1.689
Execution halted
Flavor: r-devel-linux-x86_64-fedora-clang
Version: 1.1
Check: examples
Result: ERROR
Running examples in ‘spacejam-Ex.R’ failed
The error most likely occurred in:
> ### Name: SJ
> ### Title: Estimate a graph with Spacejam
> ### Aliases: SJ SJ.dag
> ### Keywords: graphs optimize
>
> ### ** Examples
>
> #########Create graph and distribution used in Figure 2 of Voorman, Shojaie and Witten (2013):
> p <- 100 #variables
> n <- 50 #observations
>
> #Generate Graph
> set.seed(20)
> g <- rdag(p,80)
> mylayout <- layout.fruchterman.reingold(g)
>
> par(mfrow=c(1,2))
> plot(g, layout = mylayout, edge.color = "gray50",
+ vertex.color = "red", vertex.size = 3, vertex.label = NA,
+ edge.arrow.size = 0.4)
> plot(moralize(g), layout = mylayout, edge.color = "gray50",
+ vertex.color = "red", vertex.size = 3, vertex.label = NA,
+ edge.arrow.size = 0.4)
>
> #create a distribution on the DAG using cubic polynomials with random normal coefficients
> #with standard deviations of 1, 0.5 and 0.5, (i.e. giving more weight to linear association than quadratic or cubic)
> data <- generate.dag.data(g,n,basesd=c(1,0.5,0.5))
> X <- data$X
>
> #Fit conditional independence graph at one lambda , using the default basis functions (cubic polynomials).
> fit1 <- SJ(X, lambda = 0.6)
>
> #Fit conditional independence graph at 10 (hopefully reasonable) lambdas:
> fit2 <- SJ(X, length = 10)
>
> #Fit conditional independence graph using quadratic basis functions:
> fit3 <- SJ(X, bfun = function(x){cbind(x,x^2)}, length = 10)
>
> #Fit the DAG using default causal ordering 1:p, and at 10 lambdas
> fit4 <- SJ.dag(X, length = 10)
> fit4
Object of class "SJ.dag"
Contains the graphs:
lambda Edges bic
1 0.800 0 19459.10
2 0.740 9 19477.89
3 0.670 24 19493.19
4 0.600 43 19481.95
5 0.530 61 19432.97
6 0.450 109 19426.46
7 0.360 231 19648.50
8 0.270 542 20645.94
9 0.160 1134 23135.28
10 0.046 2358 27793.09
Call:
SJ.dag(X = X, length = 10)
>
> #plot the DAGs, and the true graph
> par(mfrow=c(1,3))
> plot(g, layout=mylayout, edge.color = "gray50", vertex.color = "red", vertex.size = 3, vertex.label = NA, edge.arrow.size = 0.4, main="True DAG")
> plot(fit4, layout = mylayout, which= 4, main= paste0("lambda = ",round(fit4$lambda[4],2) ))
> plot(fit4, layout = mylayout, main = "min BIC")
>
> ###For additional replications using the same DAG distribution use e.g.
> data <- generate.dag.data(g,n,funclist = data$funclist)
>
>
> #### Screen out edges whose corresponding nodes have low spearman correlation:
> # useful for approximating spacejam in high dimesnions
> S <- cor(data$X, method = "spearman")
> G.max <- S > 0.1
> mean(G.max) #~75% of edges removed
[1] 0.2458
>
> system.time({fit.screen <- SJ(X, G.max = G.max,length=20)})
----------- FAILURE REPORT --------------
--- failure: the condition has length > 1 ---
--- srcref ---
:
--- package (from environment) ---
spacejam
--- call from context ---
SJ(X, G.max = G.max, length = 20)
--- call from argument ---
if (class(G.max) == "igraph") G.max <- get.adjacency(G.max, sparse = TRUE) ==
1
--- R stacktrace ---
where 1: SJ(X, G.max = G.max, length = 20)
where 2: system.time({
fit.screen <- SJ(X, G.max = G.max, length = 20)
})
--- value of length: 2 type: logical ---
[1] FALSE FALSE
--- function from context ---
function (X, bfun = bs, lambda = NULL, length = NULL, verbose = FALSE,
b0 = NULL, maxit = 100, tol = .Machine$double.eps^0.25, G.max = NULL)
{
cl <- match.call()
bfun <- match.fun(bfun)
n <- nrow(X)
p <- ncol(X)
k <- ncol(bfun(X[, 1]))
if (!is.null(b0) & any(dim(b0) != c(n, p * k))) {
stop("dimensions of b0 not compatible with basis function")
}
if (!is.null(G.max)) {
if (class(G.max) == "igraph")
G.max <- get.adjacency(G.max, sparse = TRUE) == 1
stopifnot(storage.mode(G.max) == "logical")
stopifnot(ncol(X) == ncol(G.max))
}
if (!is.null(lambda) & !is.null(length)) {
if (length(lambda) != length)
warning("Lambda and length not compatible. Using lambda")
}
if (is.null(lambda) & is.null(length))
length = 10
if (!is.null(lambda) & any(lambda < 0))
stop("lambda must be positive")
X <- apply(X, 2, scale)
bigX <- matrix(NA, nrow = k * p, ncol = n)
for (j in 1:p) {
bigX[p * (1:k - 1) + j, ] <- t(svd(apply(bfun(X[, j]),
2, scale, scale = F))$u * sqrt(n - 1))
}
if (is.null(lambda)) {
M <- matrix(NA, nrow = p, ncol = p)
tmp <- bigX %*% X/(n - 1)
for (i in 1:p) {
for (j in (1:p)[-i]) {
M[i, j] <- sum(tmp[p * (1:k - 1) + j, i]^2)
}
}
M <- sqrt(M + t(M))
lmin <- sort(c(M))[p]
lmax <- max(M, na.rm = T)
lambda <- rev(log(seq(exp(lmin), exp(lmax), length = length)))
}
if (verbose)
cat("Progress: \n")
dfs <- rss <- matrix(0, p, length(lambda))
adjmat <- array(dim = c(p, p, length(lambda)))
for (i in 1:length(lambda)) {
out <- grpsel(X = X, bigX = bigX, lambda = lambda[i],
n = n, k = k, p = p, tol = tol, maxit = maxit, b0 = b0,
G.max = G.max)
b0 = out$b0
adjmat[, , i] <- out$G
tmp <- rowsum(t(out$betas^2) * (n - 1), rep(1:p, k))
dfs[, i] <- colSums(out$G) + (k - 1) * rowSums((tmp)/(tmp +
lambda[i]))
rss[, i] <- colSums((X - t(out$betas %*% bigX))^2)
if (verbose)
cat(".")
}
class(out) <- "SJ"
out$X = X
out$graph <- apply(adjmat, 3, function(GG) {
graph.adjacency(GG, mode = "undirected")
})
out$cl <- cl
out$bigX = bigX
out$n = n
out$k = k
out$p = p
out$tol = tol
out$maxit = maxit
out$verbose = verbose
out$G.max = G.max
out$lambda = lambda
out$G = adjmat
out$dfs = dfs
out$rss = rss
out$ecount <- unlist(lapply(out$graph, ecount))
out$bic = colSums(n * log(rss) + dfs * log(n))
return(out)
}
<bytecode: 0xadc1240>
<environment: namespace:spacejam>
--- function search by body ---
Function SJ in namespace spacejam has this body.
----------- END OF FAILURE REPORT --------------
Error in if (class(G.max) == "igraph") G.max <- get.adjacency(G.max, sparse = TRUE) == :
the condition has length > 1
Calls: system.time -> SJ
Timing stopped at: 1.474 0.087 1.747
Execution halted
Flavor: r-devel-linux-x86_64-fedora-gcc
Version: 1.1
Check: Rd line widths
Result: NOTE
Rd file 'SJ.Rd':
\examples lines wider than 100 characters:
#with standard deviations of 1, 0.5 and 0.5, (i.e. giving more weight to linear association than quadratic or cubic)
#Fit conditional independence graph at one lambda , using the default basis functions (cubic polynomials).
plot(g, layout=mylayout, edge.color = "gray50", vertex.color = "red", vertex.size = 3, vertex.label = NA, edge.arrow.size = 0.4, main=" ... [TRUNCATED]
Rd file 'generate.dag.data.Rd':
\usage lines wider than 90 characters:
generate.dag.data(g, n, basesd = 1, basemean = 0, bfuns = function(x){cbind(x, x^2, x^3)},
\examples lines wider than 100 characters:
#with standard deviations of 1, 0.5 and 0.5, (i.e. giving more weight to linear association than quadratic or cubic)
Rd file 'spacejam-package.Rd':
\examples lines wider than 100 characters:
#with standard deviations of 1, 0.5 and 0.5, (i.e. giving more weight to linear association than quadratic or cubic)
plot(g, layout=mylayout, edge.color = "gray50", vertex.color = "red", vertex.size = 3, vertex.label = NA, edge.arrow.size = 0.4, main=" ... [TRUNCATED]
These lines will be truncated in the PDF manual.
Flavors: r-patched-linux-x86_64, r-release-linux-x86_64