int_sfdr: Intersection Method

Description Usage Arguments Value Author(s) Examples

View source: R/1-estimatePi.R

Description

This function implement interesection decision rule in detecting simultaneous signals.

Usage

1
int_sfdr(p1, p2)

Arguments

p1, p2

two vectors of p-values from two independent experiments.

Value

A list consisting of

Author(s)

Yet Nguyen <[email protected]>.

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
37
38
39
40
41
42
43
44
set.seed(1)
n <- 1000
n11 <- 100; n10 <- n01 <- 100; n00 <- n - (n11 + n10 + n01)
mu1 <- rep(0, n)
mu1[1:(n11+n10)] <- rnorm(n = n11+n10, mean = 6,sd = 1)
mu2 <- rep(0, n)
mu2[c(1:n11, (n11+n10+1):(n11+n10+n01))] <- rnorm(n = n11+n01, mean = 6,sd = 1)
t1 <- plyr::laply(1:n, function(i)rt(n = 1, df = 4, ncp = mu1[i]))
p1 <- plyr::laply(1:n, function(i)2*pt(q = abs(t1[i]), df = 4, ncp = 0, lower.tail = FALSE))
t2 <- plyr::laply(1:n, function(i)rt(n = 1, df = 4, ncp = mu2[i]))
p2 <- plyr::laply(1:n, function(i)2*pt(q = abs(t2[i]), df = 4, ncp = 0, lower.tail = FALSE))
int_sfdr_out <- int_sfdr(p1, p2)
lab <- as.factor(c(rep(1, n11), rep(0, n - n11)))
pauc_out(int_sfdr_out, lab = lab)

set.seed(1)
n <- 10000
n11 <- 50; n10 <- n01 <- 1000; n00 <- n - (n11 + n10 + n01)
mu1 <- rep(0, n)
mu1[1:(n11+n10)] <- rnorm(n = n11+n10, mean = 6,sd = 1)
mu2 <- rep(0, n)
mu2[c(1:n11, (n11+n10+1):(n11+n10+n01))] <- rnorm(n = n11+n01, mean = 6,sd = 1)
library(ssa)
pm <- proc.time()
out <- laply(1:5, function(i){
 set.seed(i)
 print(i)
 t1 <- plyr::laply(1:n, function(i)rt(n = 1, df = 4, ncp = mu1[i]))
 p1 <- plyr::laply(1:n, function(i)2*pt(q = abs(t1[i]), df = 4, ncp = 0, lower.tail = FALSE))
 t2 <- plyr::laply(1:n, function(i)rt(n = 1, df = 4, ncp = mu2[i]))
 p2 <- plyr::laply(1:n, function(i)2*pt(q = abs(t2[i]), df = 4, ncp = 0, lower.tail = FALSE))
 int_sfdr_out <- int_sfdr(p1, p2)
 lab <- as.factor(c(rep(1, n11), rep(0, n - n11)))
 out <- pauc_out(int_sfdr_out, lab = lab)
 tt <- ssa::fsdr(p1, p2, m1 = n/2, m2 = n/2, alpha = .05)
 R0 <- sum(p1 <=tt[1] & p2 <= tt[2])
 V0 <- sum(which(p1 <=tt[1] & p2 <= tt[2])>n11)
 FDR0 <- V/max(1,R)
 out1 <- c(out, R0 = R0, V0 = V0, FDR0 = FDR0)
 out1
}
)
apply(out, 2, mean)
proc.time()-pm

ntyet/sfdr documentation built on Jan. 13, 2018, 6:50 a.m.