2
$\begingroup$

I realize this is an incredibly basic question; I'm really new to R (and statistics for that matter).

My data set is really simple. I surveyed 40 people, collected their demographic data, and asked them five Yes or No questions. So, the independent variables are categorical (Age, Sex, Race) and the dependent variable is the number of yes responses.

That means there are six possibilities (0 to 5 Yes) for the dependent variable. It doesn't seem like that should be treated with as.factor(), but also seems really limited to be consider continuous, as.numeric(). I've run different models (lm,lrm,glm), but the best to use obviously depends on what kind of dependent variable I'm dealing with.

Thanks in advance.

$\endgroup$
1
  • $\begingroup$ You should either select an answer or ask a subsequent question. $\endgroup$ Commented Apr 20, 2015 at 14:19

1 Answer 1

2
$\begingroup$

You could do two things. First, you could run five separate logit models to estimate the effect of your covariates on each of the individual questions. Alternatively, if you want to combine the responses into a single dependent variable (as you're currently doing), you could fit an ordered logit.

Here's an example. First, generate some data.

set.seed(1)
Age <- sample(seq(18, 60), 50, replace = TRUE)
Male <- sample(c(0,1), 50, replace = TRUE)
Race <- sample(c(1,2,3,4,5), 50, replace = TRUE)
Outcome <- sample(seq(0,5), 50, replace = TRUE)

Where Race is a categorical variable with 5 values. We'll make dummies for those. So we need to convert Race and Outcome to factors.

Race <- as.factor(Race)
Outcome <- as.factor(Outcome)

We'll use the polr function in the MASS package.

library(MASS)
mod <- polr(Outcome ~ Age + Male + Race)
summary(mod)

Re-fitting to get Hessian

Call:
polr(formula = Outcome ~ Age + Male + Race)

Coefficients:
         Value Std. Error  t value
Age   -0.00335    0.02342 -0.14304
Male   0.06317    0.53430  0.11824
Race2  0.07479    0.85805  0.08716
Race3  0.97263    0.79492  1.22356
Race4  0.45134    0.81075  0.55669
Race5  0.75757    0.91723  0.82594

Intercepts:
    Value   Std. Error t value
0|1 -2.1091  1.2473    -1.6909
1|2 -0.5995  1.1826    -0.5069
2|3  0.1289  1.1827     0.1090
3|4  1.0021  1.1970     0.8372
4|5  1.7209  1.2139     1.4176

Residual Deviance: 172.3065 AIC: 194.3065

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.