edge.fit: Fits Model to Data

Description Usage Arguments Author(s) Examples

Description

Fits model to data and returns many objects useful when performing hypotheses tests.

Usage

1
edge.fit(edge.obj, odp = FALSE)

Arguments

edge.obj

Object of class edge

odp

Flag determining whether or not to implement ODP on P-values.

Author(s)

John D. Storey <jstorey@princeton.edu>

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
45
46
47
48
49
50
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (edge.obj, odp = FALSE) 
{
    err.func = "edge.fit"
    dat = edge.obj$dat
    n = edge.obj$n.arrays
    xx0 = edge.obj$adj.var
    df0 = edge.obj$df.null
    if (!odp) {
        xx1 = cbind(edge.obj$adj.var, edge.obj$bio.var)
    }
    else {
        xx1 = edge.obj$bio.var
    }
    df1 = edge.obj$df.full
    if (!is.null(edge.obj$ind)) {
        xxi = edge.obj$ind
        Hi = xxi %*% solve(t(xxi) %*% xxi) %*% t(xxi)
        fit.ind = t(Hi %*% t(dat))
        dat = dat - fit.ind
        xx1 = xx1 - Hi %*% xx1
        xx0 = xx0 - Hi %*% xx0
        xx1 = rm.zero.cols(xx1)
        xx0 = rm.zero.cols(xx0)
    }
    H0 = xx0 %*% solve(t(xx0) %*% xx0) %*% t(xx0)
    fit0 = t(H0 %*% t(dat))
    res0 = dat - fit0
    if (odp) {
        xx1 = xx1 - H0 %*% xx1
        H1 = xx1 %*% solve(t(xx1) %*% xx1) %*% t(xx1)
        fit1 = t(H1 %*% t(res0))
        res1 = res0 - fit1
        var1 = rowSums(res1^2)/(n - df1)
        var0 = rowSums(res0^2)/(n - df0)
        return(list(fit1 = fit1, fit0 = fit0, res1 = res1, res0 = res0, 
            var1 = var1, var0 = var0, ind = edge.obj$ind, odp = odp))
    }
    else {
        H1 = xx1 %*% solve(t(xx1) %*% xx1) %*% t(xx1)
        fit1 = t(H1 %*% t(dat))
        res1 = dat - fit1
        return(list(fit0 = fit0, res1 = res1, res0 = res0, ind = edge.obj$ind, 
            odp = odp))
    }
  }

Sage-Bionetworks/snm documentation built on May 9, 2019, 12:14 p.m.