Package 'lmrse'

Title: Linear regression with clustered robust standard errors
Description: Longtiudinal analysis of high-dimensional data using linear regression with clustered robust standard errors across markers.
Authors: James Staley [aut, cre]
Maintainer: James Staley <[email protected]>
License: GPL-3
Version: 0.0.7
Built: 2024-10-01 03:36:14 UTC
Source: https://github.com/jrs95/lmrse

Help Index


Combine lmrse object into a results data.frame

Description

coerce.lmrse constructs a results data.frame from an "lmrse" object, where coefficients, standard errors and p-values for each covariable are placed in consecutive columns.

Usage

coerce.lmrse(x)

Arguments

x

an object of class "lmrse"

Value

coerce.lmrse returns a results data.frame with coefficients, standard errors and p-values for the covariables.

Author(s)

James Staley [email protected]


Linear regression model with cluster robust standard errors

Description

lmrse fits a linear regression model with cluster robust standard errors for all markers.

Usage

lmrse(formula, cluster, data = NULL)

Arguments

formula

containing the marker matrix as the response and the exposure and covariates as the dependent terms

cluster

clustering variable

data

an optional data.frame which contains the covariates specified in the formula

Value

lmrse returns a list of coefficients, standard errors and p-values matrices:

coef

a matrix of regression coefficients

se

a matrix of standard errors

p

a matrix of p-values

Author(s)

James Staley [email protected]

Examples

# Data
y <- rnorm(5000000)
y <- matrix(y, ncol = 1000)
colnames(y) <- paste0("var", 1:1000)
x <- rnorm(5000)
cluster <- rep(1:1000, 5)
c1 <- rbinom(5000, 1, 0.5)
c2 <- rnorm(5000)

# Analyses
res <- lmrse(y ~ x + c1 + c2, cluster = cluster)

Print lmrse

Description

print method for class "lmrse".

Usage

## S3 method for class 'lmrse'
print(x, ...)

Arguments

x

an object of class "lmrse"

Author(s)

James Staley [email protected]


Print summary lmrse

Description

print.summary method for class "lmrse".

Usage

## S3 method for class 'summary.lmrse'
print(x, ...)

Arguments

x

an object of class "lmrse"

Author(s)

James Staley [email protected]


Sandwich SE

Description

sandwich.se fits cluster robust standard errors using a sandwich estimator.

Usage

sandwich.se(model, cluster)

Arguments

model

output from linear model

cluster

clustering variable

Value

sandwich.se returns a vector of robust standard errors for the covariables including the intercept.

Author(s)

James Staley [email protected]

Examples

# Data
y <- rnorm(5000)
x <- rnorm(5000)
cluster <- rep(1:1000, 5)
c1 <- rbinom(5000, 1, 0.5)
c2 <- rnorm(5000)

# Analyses
model <- lm(y ~ x + c1 + c2)
se <- sandwich.se(model = model, cluster = cluster)

Summary of lmrse

Description

summary method for class "lmrse".

Usage

## S3 method for class 'lmrse'
summary(x, ...)

Arguments

x

an object of class "lmrse"

Author(s)

James Staley [email protected]