Locfdr.R

From Organic Design wiki
Revision as of 12:16, 10 July 2007 by Sven (talk | contribs) (New page: # 1) simulation page 17 p <- 1000 n <- 10 Ind <- matrix(rep(rep(c(-1,1), each=n), each=p), nr=p) Sb <- 20 u <- matrix(rnorm(p*2*n, 0, 1 ), nr=p, nc=2*n) B <- matrix(rnorm(p*2*n, 0, Sb)...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
  1. 1) simulation page 17

p <- 1000 n <- 10 Ind <- matrix(rep(rep(c(-1,1), each=n), each=p), nr=p)


Sb <- 20 u <- matrix(rnorm(p*2*n, 0, 1 ), nr=p, nc=2*n) B <- matrix(rnorm(p*2*n, 0, Sb), nr=p, nc=2*n)

X <- u + B*Ind/2

cl <- rep(0:1, each=n)

  1. 2) multtest

library(multtest) teststat <- mt.teststat(X, cl) hist(teststat)

  1. 3) locfdr

library(locfdr)

locfdr(teststat, type=1) locfdr(teststat, type=0)

q0 <- seq(-4,4, length=1001) null <- dnorm(q0) lines(q0, null*80, type="l", col="red")

lines(theoretical*10000, col="red") tmp <- density(theoretical) tmp$y <- tmp$y*p/10 lines(tmp, col="red")