bigLMStats | R Documentation |
This function simplifies calculating p-values from linear models in which
there are many outcome variables, such as in voxel-wise regressions. To
perform such an analysis in R, you can concatenate the outcome variables
column-wise into an n by p matrix y
, where there are n subjects and p
outcomes (see Examples
). Calling lm(y~x)
calculates the
coefficients, but statistical inference is not provided. This function
provides basic statistical inference efficiently.
bigLMStats(mylm, lambda = 0, includeIntercept = FALSE)
mylm |
Object of class |
lambda |
Value of ridge penalty for inverting ill-conditioned matrices. |
includeIntercept |
Whether or not to include p-values for intercept term in result. |
A list containing objects:
fstat |
F-statistic of whole model (one value per outcome). |
pval.model |
p-value of model (one value per outcome). |
beta |
Values of coefficients (one value per predictor per outcome). |
beta.std |
Standard error of coefficients. |
beta.t |
T-statistic of coefficients. |
beta.pval |
p-value of coefficients. |
Kandel BM.
nsub <- 100
set.seed(1500)
x <- 1:nsub
y <- matrix(c(x + rnorm(nsub), sin(x)), nrow = nsub)
x <- cbind(x, x^2)
y1 <- y[, 1]
y2 <- y[, 2]
lm1 <- lm(y1 ~ x)
lm2 <- lm(y2 ~ x)
mylm <- lm(y ~ x)
myest <- bigLMStats(mylm)
print(paste(
"R beta estimates for first outcome is", summary(lm1)$coefficients[-1, 1],
"and for second outcome is", summary(lm2)$coefficients[-1, 1]
))
print(paste("and our estimate is", as.numeric(myest$beta[, 1]), as.numeric(myest$beta[, 2])))
print(paste(
"R std error estimate for first outcome is", summary(lm1)$coefficients[-1, 2],
"and for second outcome is", summary(lm2)$coefficients[-1, 2],
"and our estimate is", myest$beta.std[, 1], myest$beta.std[, 2]
))
print(paste(
"R t value estimate for first outcome is", summary(lm1)$coefficients[-1, 3],
"and for second outcome is", summary(lm2)$coefficients[-1, 3],
"and our estimate is", myest$beta.t[, 1], myest$beta.t[, 2]
))
print(paste(
"R pval for first outcome is", summary(lm1)$coefficients[-1, 4],
"and for second outcome is", summary(lm2)$coefficients[-1, 4],
"and our estimate is", myest$beta.pval[, 1], myest$beta.pval[, 2]
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.