## 500 variables, hence 500 univariate regressions are to be fitted
x = matrix( rnorm(100 * 500), ncol = 500 )
## 100 observations in total
y = rbinom(100, 1, 0.6) ## binary logistic regression
system.time( univglms(y, x) )
a1 = univglms(y, x)
a2 <- numeric(500)
system.time( for (i in 1:500) a2[i] = glm(y ~ x[, i], binomial)$deviance )
a2 = a2 - glm(y ~ 1, binomial)$null.dev
y = rnorm(100)
system.time( univglms(y, x) )
a1 = univglms(y, x)
system.time( for (i in 1:500) a2[i] = lm.fit( cbind(1, x[, i]), y ) )
y = rpois(100, 10)
system.time( univglms(y, x) )
b1 = univglms(y, x)
b2 <- numeric(500)
system.time( for (i in 1:500) b2[i] = glm(y ~ x[, i], poisson)$deviance )
b2 = b2 - glm(y ~ 1, poisson)$null.dev
Run the code above in your browser using DataLab