Rfast (version 1.7.3)

Many multivariate simple linear regressions coefficients: Many multivariate simple linear regressions coefficients

Description

Many multivariate simple linear regressions coefficients.

Usage

mvbetas(y, x, pvalue = FALSE)

Arguments

y
A matrix with the data, where rows denotes the observations and the columns contain the dependent variables.
x
A numerical vector with one continuous independent variable only.
pvalue
If you want a hypothesis test that each slope (beta coefficient) is equal to zero set this equal to TRUE. It will also produce all the correlations between y and x.

Value

A matrix with the constant (alpha) and the slope (beta) for each simple linear regression. If the p-value is set to TRUE, the correlation of each y with the x is calculated along with the relevant p-value.

Details

It is a function somehow opposite to the allbetas. Instead of having one y and many xs we have many ys and one x.

See Also

allbetas, correls, univglms

Examples

Run this code
y <- matrix( rnorm(100 * 1000), ncol = 1000 )
x <- rnorm(100)
a <- mvbetas(y, x, pvalue = FALSE)
b <- matrix(nrow = 1000, ncol = 2)
z <- cbind(1, x)
for (i in 1:1000) b[i, ] = coef( lm.fit( z, y[, i] ) )

system.time( mvbetas(y, x) )
system.time(  for (i in 1:1000) b[i, ] = coef( lm.fit( z, y[, i] ) )  )

Run the code above in your browser using DataLab