avgrocs: Takes the vertical average of ROC curves.

Description Usage Arguments Value References Examples

View source: R/Score_init.R

Description

Takes the vertical average of ROC curves using algorithm 3 from \insertCitefaw06;textualgenscore. The resulting ROC curve preserves the average AUC.

Usage

1
avgrocs(rocs, num_true_edges, p)

Arguments

rocs

A list of ROC curves, each of which is a matrix with two columns corresponding to the true positive and false positive rates, respectively.

num_true_edges

A positive integer, the number of true edges

p

A positive integer, the dimension

Value

The averaged ROC curve, a matrix with 2 columns and (p^2-p-num_true_edges+1) rows.

References

\insertRef

faw06genscore

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
n <- 40
p <- 50
mu <- rep(0, p)
tol <- 1e-8
domain <- make_domain("R+", p=p)
K <- cov_cons(mode="sub", p=p, seed=1, spars=0.2, eig=0.1, subgraphs=10)
true_edges <- which(abs(K) > tol & diag(p) == 0)
dm <- 1 + (1-1/(1+4*exp(1)*max(6*log(p)/n, sqrt(6*log(p)/n))))
ROCs <- list()
old.par <- par(mfrow=c(2,2), mar=c(5,5,5,5))
for (i in 1:3){
  set.seed(i)
  x <- tmvtnorm::rtmvnorm(n, mean = mu, sigma = solve(K),
         lower = rep(0, p), upper = rep(Inf, p), algorithm = "gibbs",
         burn.in.samples = 100, thinning = 10)
  est <- estimate(x, setting="gaussian", elts=NULL, domain=domain, centered=TRUE,
           symmetric="symmetric", lambda_length=100, mode="min_pow",
           param1=1, param2=3, diag=dm)
  # Apply tp_fp to each estimated edges set for each lambda
  TP_FP <- t(sapply(est$edgess, function(edges){tp_fp(edges, true_edges, p)}))
  ROCs[[i]] <- TP_FP
  plot(c(), c(),  ylim=c(0,1), xlim=c(0,1), cex.lab=1,
    main=paste("ROC, trial ",i,", AUC ",round(AUC(TP_FP),4),sep=""),
    xlab="False Positives", ylab="True Positives")
  points(TP_FP[,2], TP_FP[,1], type="l")
  points(c(0,1), c(0,1), type = "l", lty = 2)
}
average_ROC <- avgrocs(ROCs, length(true_edges), p)
plot(c(), c(),  ylim=c(0,1), xlim=c(0,1), cex.lab=1,
  main=paste("Average ROC, AUC",round(AUC(average_ROC),4)),
  xlab="False Positives", ylab="True Positives")
points(average_ROC[,2], average_ROC[,1], type="l")
points(c(0,1), c(0,1), type = "l", lty = 2)
par(old.par)

Example output

Calculating elements necessary for estimation.

Calculating lower bound for lambda.

step =10

[1] "Testing lower bound for lambda:  1e-04"
Testing lower bound for lambda:1e-05
, number of edges=2450; want 2450.

step =1.77827941003892

[1] "Testing lower bound for lambda:  1e-05"
Testing lower bound for lambda:1.77827941003892e-05
, number of edges=2450; want 2450.

Testing lower bound for lambda:3.16227766016838e-05
, number of edges=2448; want 2450.

step =1.15478198468946

[1] "Testing lower bound for lambda:  1.77827941003892e-05"
Testing lower bound for lambda:2.05352502645715e-05
, number of edges=2450; want 2450.

Testing lower bound for lambda:2.37137370566166e-05
, number of edges=2448; want 2450.

Final: 2.05352502645715e-05, 2450 edges.

Calculating upper bound for lambda.

Upper bound for lambda: 0.549496706813624.

Calculating estimates.

1% done

2% done

5% done

10% done

20% done

30% done

40% done

50% done

60% done

70% done

80% done

90% done

100% done

Done.

Calculating elements necessary for estimation.

Calculating lower bound for lambda.

step =10

[1] "Testing lower bound for lambda:  1e-04"
Testing lower bound for lambda:1e-05
, number of edges=2450; want 2450.

step =1.77827941003892

[1] "Testing lower bound for lambda:  1e-05"
Testing lower bound for lambda:1.77827941003892e-05
, number of edges=2450; want 2450.

Testing lower bound for lambda:3.16227766016838e-05
, number of edges=2450; want 2450.

Testing lower bound for lambda:5.62341325190349e-05
, number of edges=2448; want 2450.

step =1.15478198468946

[1] "Testing lower bound for lambda:  3.16227766016838e-05"
Testing lower bound for lambda:3.65174127254838e-05
, number of edges=2450; want 2450.

Testing lower bound for lambda:4.21696503428582e-05
, number of edges=2450; want 2450.

Testing lower bound for lambda:4.86967525165863e-05
, number of edges=2450; want 2450.

Testing lower bound for lambda:5.62341325190349e-05
, number of edges=2448; want 2450.

Final: 4.86967525165863e-05, 2450 edges.

Calculating upper bound for lambda.

Upper bound for lambda: 0.586832804195988.

Calculating estimates.

1% done

2% done

5% done

10% done

20% done

30% done

40% done

50% done

60% done

70% done

80% done

90% done

100% done

Done.

Calculating elements necessary for estimation.

Calculating lower bound for lambda.

step =10

[1] "Testing lower bound for lambda:  1e-04"
Testing lower bound for lambda:1e-05
, number of edges=2450; want 2450.

step =1.77827941003892

[1] "Testing lower bound for lambda:  1e-05"
Testing lower bound for lambda:1.77827941003892e-05
, number of edges=2450; want 2450.

Testing lower bound for lambda:3.16227766016838e-05
, number of edges=2450; want 2450.

Testing lower bound for lambda:5.62341325190349e-05
, number of edges=2450; want 2450.

Testing lower bound for lambda:1e-04
, number of edges=2448; want 2450.

step =1.15478198468946

[1] "Testing lower bound for lambda:  5.62341325190349e-05"
Testing lower bound for lambda:6.49381631576211e-05
, number of edges=2448; want 2450.

Final: 5.62341325190349e-05, 2450 edges.

Calculating upper bound for lambda.

Upper bound for lambda: 0.610964276340833.

Calculating estimates.

1% done

2% done

5% done

10% done

20% done

30% done

40% done

50% done

60% done

70% done

80% done

90% done

Done.

genscore documentation built on April 28, 2020, 1:06 a.m.