delta_deviance_lf: Calculate delta deviance of logistic null/alternative models

View source: R/delta_deviance_lf.R

delta_deviance_lfR Documentation

Calculate delta deviance of logistic null/alternative models

Description

This function fits, at each locus of a given genotype matrix, two logistic models, and under the assumption that the models are nested, calculates the delta deviance between the two. This general function is intended for testing models in a broad setting; for the specific problem of genetic association, the interface in gcat() and gcat.stat() are more user-friendly.

Usage

delta_deviance_lf(X, LF0, LF1)

Arguments

X

A matrix of SNP genotypes, i.e. an integer matrix of 0's, 1's, 2's and NAs. BEDMatrix is supported. Sparse matrices of class Matrix are not supported (yet).

LF0

Logistic factors for null model.

LF1

Logistic factors for alternative model.

Value

The vector of delta deviance values, one per locus of X.

Examples

library(lfa)

# make example data smaller so example is fast
# goes from 1000 to 100 individuals
indexes <- sample.int( ncol(sim_geno), 100 )
sim_geno <- sim_geno[ , indexes ]
sim_trait <- sim_trait[ indexes ]

# now run LFA and get delta deviances for trait assoc
# (recapitulating `gcat.stat` in this case)
LF <- lfa(sim_geno, 3)
LF0 <- LF # structure is null
LF1 <- cbind(LF, sim_trait) # trait is alt
devdiff_assoc <- delta_deviance_lf(sim_geno, LF0, LF1)

# can instead do delta deviances for structure only
LF0 <- cbind(rep.int(1, ncol(sim_geno))) # intercept only is null
LF1 <- LF # structure is alt, no trait
devdiff_struc <- delta_deviance_lf(sim_geno, LF0, LF1)


StoreyLab/gcatest documentation built on Nov. 13, 2022, 4:22 a.m.