According to Quick-R, logistic regression or logit is a regression model you do when you are predicting a binary outcome from a set of continuous predictor variables.In my case, I was studying the effect of several continuous variables on a binary output: to have skin wounds.
I used the glm() function (glm stands for General Linear Model), wounds is the binary output (1- wound; 0- no wounds), and several continuous variables (va1…var12).
These were my commands:
attach(data) fit <- glm(wounds~var1+var2+var3, family = 'binomial') detach(data)
Then, a bunch of commands may be useful to extract coefficients and values from fit:
summary(fit) # display results confint(fit) # 95% CI for the coefficients exp(coef(fit)) # exponentiated coefficients exp(confint(fit)) # 95% CI for exponentiated coefficients
However, once I have studied the data, they can be displayed in a very nice way:
col_1 <- round(exp(cbind(OR=coef(fit), confint(fit))), digits = 2) col_2 <- round(coef(summary(fit))[,4], digits = 2) # final_table <- cbind(col1, p.value=col2)
By the way, this command:
extracts the p-values.
The outcome is a table like this:
OR 2.5 % 97.5 % p.value (Intercept) 0.01 0.00 0.09 0.06 var1 0.84 0.26 0.27 0.77 var2 1.12 1.02 1.25 0.03 var3 0.91 0.69 1.19 0.48 var4 4.13 0.78 2.76 0.11
And that’s all.