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])) {
fit <- glm(data[,1] ~ data[,i], data = df, etc...)
datout[i,] <- fit[e.g, 1:4] # determine what values in your model output are
what you need
}
datout # a table with all your output for each variable
On Sunday, May 8, 2011 at 11:58 AM, SevannaD wrote:
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), each of their 95% confidence intervals, and each of thier
> odds ratios and place them in a matrix to showcase them for my thesis.
>
> currently, I am writing them all out one by one with the cbond method,
which
> has taken me a better part of a day so far and I know there has to be able
> to be a way to make a loop that can do this whole process, I just havent
> been able to figure it out yet.
>
> Thanks in advance.
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/new-to-loops-tp3507366p3507366.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]