How to run logistic regression in R? I am getting very confused at my data.
I want to run a simple logistic regression:
IV is called FIRST_cat: High or Low (grouping on a questionnaire)
DV is called InsomniaT3: High or Low(Grouping on a questionnaire)
Both are scored as factors on R.
Code sample below:
REGRESSION <- glm(InsomniaT3 ~ FIRST_cat, data = tidydata, 
                  family = "binomial"(logit))
summary(REGRESSION)


## Output:
Call:
glm(formula = InsomniaT3 ~ FIRST_cat, family = binomial(logit), 
    data = tidydata)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-1.3964  -0.8532   0.9732   0.9732   1.5409  

Coefficients:
              Estimate Std. Error z value Pr(>|z|)    
(Intercept)    -0.8232     0.2827  -2.911  0.00360 ** 
FIRST_catHigh   1.3247     0.3425   3.868  0.00011 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 239.68  on 172  degrees of freedom
Residual deviance: 223.67  on 171  degrees of freedom
AIC: 227.67

Number of Fisher Scoring iterations: 4

I don't understand this output at all. Could someone explain if this is correct? Do i have to dummy code variables? Also when i add in other continuous predictors, they don't seem to show up in the output.
 A: As you are using factors, glm automatically uses dummy variables to estimate your coefficients. It created 2 dummies: one for FIRST_cat = "High", named FIRST_catHigh, and other for FIRST_cat = "Low", but as you can't add both on the model (because of multicolinearity problems), it uses only one.
The coefficient associated with the intercept can now be interpreted as:
E[InsomniaT3 | FIRST_cat = "Low"]

And the associated with the FIRST_catHigh can be interpreted as:
E[InsomniaT3 | FIRST_cat = "High"] - E[InsomniaT3 | FIRST_cat = "Low"]

A: *

*When writing it up, you should interpret the model as follows. Your
variable "FIRST_cat" was significant, you can reject the null
hypothesis that it is equal to zero. If that variable is "high" it
has a positive effect, otherwise a negative effect. Furthermore, that means that the probability of "InsomniaT3" being "high" increases/decreases (depending on how it is coded).


*AIC is a measurement of how well your model can predict unobserved
data, relative to other models on the same data. If you have only
applied one model to your data, the AIC provides no valuable
information. If you compare several models, you want your AIC to be as low as possible.


*As for other goodness of fit statistics, you could check for multicolinarity (VIF values). You can check model assumptions, such as linear dependeancy on the logit scale for your predictors. You can check for outliers in your data (Cook's distance).
