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


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.


delta_deviance_lf(X, LF0, LF1)



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).


Logistic factors for null model.


Logistic factors for alternative model.


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



# make example data smaller so example is fast
# goes from 1000 to 100 individuals
indexes <- 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(, 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 March 7, 2024, 9:59 p.m.