qpPathWeight {qpgraph} | R Documentation

## Calculation of path weights

### Description

Calculates the path weight for a path of an undirected graph.

### Usage

    ## S4 method for signature 'matrix'
    qpPathWeight(X, path, Q=integer(0), M=integer(0),
                                    normalized=TRUE, R.code.only=TRUE)

### Arguments

`X` | covariance matrix.
`path` | character vector of consecutive vertex names defining a path in an undirected graph.
`Q` | indexes or names of the variables in `sigma` that should be used for conditioning.
`M` | indexes or names of the variables in `sigma` over which we want to marginalize.
`normalized` | logical; TRUE (default) when the calculated path weight should be normalized so that weights are comparable between paths with different endpoints, and false otherwise.
`R.code.only` | logical; if FALSE then the faster C implementation is used (not yet available); if TRUE then only R code is executed (default).

### Details

Calculation of path weights. This implementation is still under development and will give only correct results with either population covariance matrices or sample covariance matrices estimated from data with n >> p. Consult (Roverato and Castelo, 2017) for further details.

### Value

The calculated path weight for the given path.

### Author(s)

R. Castelo and A. Roverato

### References

Roverato, A. and Castelo, R. The networked partial correlation and its application to the analysis of genetic interactions. J. R. Stat. Soc. Ser. C-Appl. Stat., 66:647-665, 2017. http://dx.doi.org/10.1111/rssc.12166

### Examples

    ## example in Figure 1 from (Castelo and Roverato, 2017)

    ## undirected graph on 9 vertices
    edg <- matrix(c(1, 4,
                    2, 4,
                    3, 4,
                    4, 5,
                    5, 6,
                    5, 7,
                    8, 9),
                ncol=2, byrow=TRUE)

    ## create a corresponding synthetic precision matrix with
    ## partial correlation values set to -0.4 for all present edges
    K <- matrix(0, nrow=9, ncol=9, dimnames=list(1:9, 1:9))
    K[edg] <- -0.4
    K <- K + t(K)
    diag(K) <- 1

    ## calculate the corresponding covariance matrix
    S <- solve(K)

    ## calculate networked partial correlations for all present
    ## edges
    npc <- sapply(1:nrow(edg), function(i) qpPathWeight(S, edg[i, ]))

    ## note that while all partial correlations are zero for missing
    ## edges and are equal to -0.4 for present edges, the corresponding
    ## networked partial correlations are also zero for missing edges
    ## but may be different between them for present edges, depending on
    ## the connections between the vertices
    cbind(edg, npc)

[Package qpgraph version 2.21.2 Index]