0
$\begingroup$

I am looking to run regression using a variety of predictor variables: Chemical exposure (1 or 0) - variety of chemicals but all are binary predictors, Illness diagnosis (1 or 0), and TBI severity (0 1 2 3, while controlling for education, age,sex, military rank etc.

Overall, I am trying to predict the outcome on the response score (# of correct answers) for various psychological test.

I am a bit confused on how I should set up my regression model given that I have a combination of categorical and continuous variables to predict continuous response. I'm thinking of using a glm model in R, but I am not exactly sure what family to use and how to view it graphical since most responses are binary.

Thoughts/Help is greatly appreciated

Thank you!

$\endgroup$
  • $\begingroup$ Trying to use predictors: Chemical exposure, Illness diagnosis, TBI severity --> all of which are categorical variables to look at response: # of correct answers --> which is a continuous variable $\endgroup$ – Cody Sep 20 '18 at 18:14
  • $\begingroup$ An example model includes this: glm(formula = BNT$TBI ~ BNT$CorrectSpontaneous + BNT$cPTSD + BNT$cMDD + BNT$HxETOH + BNT$HxDrug + BNT$edu) --> Predict the severity of their TBI given how many answers they got correctly while controlling for PTSD, depression, alcohol/drug use and education; alternatively I can predict the # of correct answers they will get given their TBI severity and controlling for variables above. Which model would be better and what would be family in model? $\endgroup$ – Cody Sep 20 '18 at 18:22
0
$\begingroup$

You can use the family=binomial option of the glm() function, and specify the # correct answers and # incorrect answers as the target variable, as described in the documentation for family:

For the binomial and quasibinomial families the response can be specified in one of three ways:

...

  1. As a two-column integer matrix: the first column gives the number of successes and the second the number of failures.

Here is a very simple example, where I have included two predictor variables, one continuous (x) and one binary (flag):

df <- data.frame(
  trials=c(5, 8, 10, 3, 4),
  successes=c(2, 7, 1, 2, 3),
  x=c(0.8, 3.2, 0.2, 1.0, 1.3),
  flag=c(0, 1, 1, 1, 0)
)

summary( glm(cbind(successes, trials-successes) ~ x + flag, family=binomial, data=df) )

which gives the following output when I run it (R-3.5.1 64-bit):

Call:
glm(formula = cbind(successes, trials - successes) ~ x + flag, family = binomial, 
    data = df)

Deviance Residuals: 
      1        2        3        4        5  
-0.3732  -0.3753  -0.5558   1.0811   0.4464  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)   
(Intercept)  -1.1402     0.8477  -1.345   0.1786   
x             1.3404     0.5005   2.678   0.0074 **
flag         -0.7803     0.9165  -0.851   0.3946   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 14.011  on 4  degrees of freedom
Residual deviance:  1.957  on 2  degrees of freedom
AIC: 17.196

Number of Fisher Scoring iterations: 4
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.