0

I'm trying to run some diagnostics on a binary logistic regression model. Specifically, the marginal model plots. Unfortunately, I keep getting the "need finite 'xlim' values" error. The code below reproduces the issue. My model includes both numeric and categorical variables (which get converted to dummy variables in the model). Anyway, I know this error can occur when all values are NA, but that isn't the case for any of my data and I'm not sure whats going on.

set.seed(020275)
df <- data.frame(y=sample(c(0,1), 10, replace=TRUE), 
             cat=sample(c("Red", "Blue", "Green"), 10, replace=TRUE), 
             loc=sample(c("North", "South", "East", "West"), 10,  replace=TRUE), 
             count=runif(10, 0, 10),
             stringsAsFactors = FALSE)

glmModel <- glm(y ~ cat + loc + count, family=binomial(), data=df)
glmModel

library(car)
marginalModelPlots(glmModel)

I get the following error:

Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf

Looking for some ideas/suggestions/guidance on how to deal with this.

Daniel D.
  • 134
  • 1
  • 4
  • 7
  • Have you tried using: mmp(glmModel) instead? – Dave2e Apr 14 '16 at 02:46
  • Right, good point. mmp works, but I only see the whole linear predictor plot. I'm looking for the individual predictor plots as well (which are included with the mmps version of the function). – Daniel D. Apr 14 '16 at 03:02

1 Answers1

0

It appears the character data typed vectors (cat and loc in the example above) are not compatible with marginalModelPlots, at least for the version of the car package I'm currently using (2.1-1). I found I could use the terms parameter to limit the plots to a subset of the variables while also including the Linear Predictor plot (as shown below).

marginalModelPlots(glmModel, terms= ~ count)

maringalModelPlots image

Daniel D.
  • 134
  • 1
  • 4
  • 7