lm_test: Function that will allow for (apply) to be used for linear...

Description Usage Arguments Value Examples

View source: R/lm_test.R

Description

Function that will allow for (apply) to be used for linear regressions This function will do a single linear regression and extract the coefficients from the regression.

Usage

1
2
lm_test(lm_data, count, covariates = "", correct_for = "",
  outlier_sd = 3, omit.outlier = T)

Arguments

lm_data

Our dependent variables. Column = dependent variable, rows = observations (in this case, individuals) (numeric vector)

count

Our independent variable (numeric vector)

covariates

Covariates associated with each individual. Columns = covariates, rows = observations. (data.frame)

outlier_sd

Outliers that are greater than outlier_sd standard devs from the mean will be filtered out

to_correct

A string containing additional covariates to correct for. ex: '+as.factor(covariates$DTHHRDY)+as.factor(covariates$RACE)'

Value

Coefficients from the regression

Examples

1
subcut_lm_results <- apply(subcut_for_test, 2, lm_test, count = MT_count, covariates = covariates, correct_for = '+ as.factor(covariates$GENDER) + as.numeric(covariates$AGE)+ as.numeric(covariates$smrin) + as.factor(covariates$smcenter) + as.factor(covariates$RACE)+ as.numeric(covariates$TRISCHD) +as.factor(covariates$COHORT) + as.factor(covariates$DTHHRDY) + covariates$PC1 + covariates$PC2 +covariates$PC3+ covariates$PC4 + covariates$PC5')

syyang93/analyzeR documentation built on Aug. 26, 2020, 4:34 p.m.