Learn R Programming

gtx (version 0.0.8)

lm.moments2: Fit normal linear model using pre-built matrix of second moments.

Description

Regression coefficients for a normal linear model are be calculated, using a pre-built sufficient summary statistic matrix that contains the second moments between all the variables of (potential) interest.

Usage

lm.moments2(xtx, leftvar, rightvars, n = NULL)

Arguments

xtx
a matrix of second moments, typically built using make.moments2.
leftvar
name of the response variable (the left hand side of the formula).
rightvars
name(s) of the explanatory variables (the right hand side of the formula).
n
sample size, only needed if there is not a single intercept for all individuals.

Value

A list with slots for the effect size estimates, standard errors, and a precision matrix.This function is just a wrapper for calling est.moments2 with scale = NULL.

Details

Non-identifiable variables in rightvars are removed, with preference for keeping variables that occur earlier rather than later in rightvars.

Examples

Run this code
data(mthfrex)
xtx <- make.moments2(mthfr.params, c("SBP", "DBP", "SexC", "Age"), mthfrex)
lm.moments2(xtx, "SBP", c("ONE", "rs6668659_T", "rs4846049_T",
                                "rs1801133_G", "SexC", "Age"))
## Compare against results from lm
## Note have to use coded alleles in original data
lm(SBP ~ rs6668659_G+rs4846049_G+rs1801133_A+Sex+Age, data = mthfrex$data)
## Note in results Sex factor coded differently than SexC

Run the code above in your browser using DataLab