I'm trying to do a logistic regression on some data.

Here's a simplified version of the situation:

I'm trying to predict student success based on their history, etc. One of my predictors is the percentage of the courses they've passed in the past. If they haven't taken any courses, I don't want to set that to zero, because that's obviously different from having failed all their courses. Right now, these cases are set as NaN, but when I use the glm function in R, I get the following error:

Error in glm.fit(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, : NA/NaN/Inf in foreign function call (arg 1)

How do I predict performance for individuals who haven't taken any courses yet?

  • 2
    $\begingroup$ Hey Mike - welcome to the site. I'd suggest reframing your question so that it's more statistical in tone. Right now, it sounds like a computation problem - but what you're really asking is, "How do I predict performance for individuals who haven't taken any courses yet?" I think you'll get better responses. $\endgroup$ – Matt Parker Jun 28 '12 at 16:53
  • 2
    $\begingroup$ You could fill in the missing values with the average pass rate from the rest of the population. $\endgroup$ – aaronjg Jun 28 '12 at 16:57
  • 1
    $\begingroup$ What is the rationale for that @aaronjg? That seems more appropriate if they're missing at random but it seems questionable to decree that someone who has never taken a course before would perform at the population average level. Perhaps something more like regressing pass rate on # of classes taken an extrapolating to 0 would be an alternative. $\endgroup$ – Macro Jun 29 '12 at 11:09
  • $\begingroup$ If you imagine that another course might help to prepare you for this one, even failing might help more than not taking a class. That depends on how poorly you have to perform to fail. $\endgroup$ – Douglas Zare Jun 29 '12 at 16:11
  • $\begingroup$ Performance in college is often assessed by high school GPA or standardized tests like the SAT. Instead of using past courses passed as a predictor why not pick some other predictors that all the students share in common? If you feel you must use classes passed then it is probably best to treat the students with no classes taken as having that covariate missing. Imputation probably should not be done using average # of courses past by others since there is probably differences between the students who have not taken course from those that have. Macro's suggestion sounds preferable to me. $\endgroup$ – Michael R. Chernick Jun 29 '12 at 16:13

I would add a new variable to your model indicating "no past test scores", and then set the "past test score" variable equal to zero for people who have no previous scores. Then the contribution of both variables is either $\beta_{no scores}$ or $x_{scores}\beta_{scores}$. This is a general, very easy way to handle missing data. Of course this method assumes something like missing at random. You also need to have data to estimate $\beta_{noscores}$


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.