Re: [R] new to loops

2011-05-08 Thread sunny
Maybe this is what you're looking for: # x is your set of explanatory variables (10 of them): x <- array(rnorm(1), dim=c(1000,10)) # y is your dependent variable: y <- rbinom(1000, 1, 0.3) # run the regression on each column of x: reg <- apply(x, 2, function(z) glm(y ~ z, family=binomial(lin

Re: [R] new to loops

2011-05-08 Thread SevannaD
So in my first try before I got your message, this is what I did: orconf<-list() ccoef<-list() or<-list() coef<-list() out<-list() for (i in 1:49){ out[[i]]<-glm(y~var[[i]],family=binomial(link="logit")) coef[[i]]<-out[[i]]$coef[2] or[[i]]<-exp(out[[i]]$coef[2]) bond<-matrix(out[[i]]$coef[2

Re: [R] new to loops

2011-05-08 Thread Scott Chamberlain
Not knowing what format your data is in or what model you are using... df # is your data frame with columns the variables you are running regressions for datout <- data.frame(coeff = NA, conf_low = NA, conf_high = NA, odd = NA) # a table to put your results in for(i in 1:length(names(df)[2:10]))

[R] new to loops

2011-05-08 Thread SevannaD
I have never made a loop on my own to do anything in R. But I am hoping someone can help me build one for the following issue: I need to make a univariate logistic regression for each of my variables (about 62 of them), then I need to gather up each of their coefficients (not the intercepts), eac