1
$\begingroup$

Even though this may first appear coding-related, I am not interested in the particular code, but rather in the interpretation of the resulting plots. Therefore, I though this is more appropriate here rather than on Stack Overflow.

Here are the data:

MyData <- structure(list(site = structure(c(3L, 1L, 5L, 1L, 2L, 3L, 2L, 
    4L, 1L, 2L, 2L, 3L, 4L, 3L, 2L, 2L, 4L, 1L, 1L, 3L, 3L, 1L, 4L, 
    3L, 1L, 3L, 4L, 5L, 1L, 3L, 1L, 2L, 4L, 2L, 1L, 1L, 5L, 3L, 1L, 
    3L, 4L, 3L, 1L, 4L, 4L, 2L, 5L, 2L, 1L, 4L, 1L, 1L, 1L, 4L, 4L, 
    3L, 5L, 3L, 1L, 3L, 1L, 1L, 3L, 1L, 4L, 5L, 1L, 5L, 1L, 4L, 1L, 
    4L, 1L, 2L, 5L, 2L, 3L, 1L, 5L, 4L, 1L, 1L, 3L, 2L, 1L, 3L, 5L, 
    3L, 3L, 5L, 2L, 1L, 3L, 5L, 4L, 5L, 5L, 1L, 3L, 2L, 5L, 4L, 3L, 
    3L, 2L, 5L, 2L, 1L, 1L, 3L, 3L, 5L, 5L, 5L, 3L, 1L, 1L, 5L, 5L, 
    5L, 2L, 3L, 5L, 1L, 3L, 3L, 4L, 4L, 4L, 5L, 2L, 3L, 1L, 4L, 2L, 
    4L, 3L, 4L, 3L, 3L, 4L, 1L, 3L, 4L, 1L, 4L, 4L, 5L, 4L, 4L, 1L, 
    4L, 1L, 2L, 1L, 2L, 4L, 2L, 4L, 3L, 5L, 1L, 2L, 3L, 1L, 1L, 4L, 
    3L, 1L, 1L, 1L, 4L, 3L, 5L, 4L, 2L, 1L, 4L, 1L, 2L, 1L, 1L, 5L, 
    1L, 5L, 3L, 1L, 5L, 3L, 5L, 3L, 5L, 3L, 1L, 5L, 1L, 1L, 1L, 3L, 
    1L, 4L, 4L, 2L, 5L, 4L, 1L, 3L, 2L, 4L, 5L, 4L, 5L, 5L, 3L, 2L, 
    2L, 4L, 2L, 5L, 4L, 1L, 5L, 5L, 4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L, 4L, 1L, 4L, 4L, 4L, 4L, 4L, 
    3L, 3L, 4L, 4L, 4L, 3L, 5L, 4L, 3L, 4L, 4L, 3L, 4L, 4L, 4L, 
    4L, 4L, 4L, 4L, 3L, 4L, 3L, 4L, 1L, 4L, 4L, 3L, 4L, 4L, 4L, 
    4L, 4L, 3L, 4L, 3L, 3L, 4L, 4L, 3L, 4L, 3L, 4L, 3L, 4L, 3L, 
    4L, 4L, 2L, 4L, 4L, 3L, 4L, 1L, 3L, 4L, 4L, 4L, 3L, 3L, 3L, 
    4L, 3L, 3L, 3L, 4L, 4L, 4L, 2L, 5L, 4L, 4L, 3L, 3L, 3L, 4L, 
    4L, 4L, 1L, 4L, 4L, 1L, 4L, 4L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 
    4L, 4L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 3L, 4L, 4L, 3L, 2L, 
    4L, 4L, 4L, 1L, 4L, 3L, 3L, 3L, 4L, 3L, 2L, 4L, 4L, 4L, 4L, 
    3L, 4L, 4L, 3L, 3L, 1L, 4L, 3L, 1L, 4L, 4L, 3L, 4L, 4L, 4L, 
    4L, 3L, 4L, 1L, 4L, 1L, 3L, 4L, 3L, 3L, 4L, 2L, 4L, 3L, 4L, 
    3L, 4L, 4L, 4L, 4L, 4L, 3L, 4L, 4L, 4L, 2L, 3L, 4L, 4L, 3L, 
    2L, 4L, 4L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 4L, 1L, 4L, 2L, 4L, 
    4L, 4L, 4L, 1L, 4L, 5L, 4L, 4L, 3L, 3L, 3L, 4L, 4L, 4L, 3L, 
    4L, 3L, 3L, 3L, 4L, 3L, 2L, 4L, 4L, 3L, 4L, 4L, 4L, 5L, 1L, 
    3L, 2L, 4L, 3L, 4L, 4L, 4L, 3L, 4L, 3L, 4L, 4L, 3L, 3L, 4L, 
    4L, 4L), .Label = c("East", "Flat", "North", "South", "West"
    ), class = "factor"), height = c(515L, 60L, 60L, 30L, 70L, 
    70L, 40L, 70L, 50L, 75L, 160L, 85L, 40L, 90L, 70L, 210L, 
    30L, 60L, 45L, 60L, 410L, 50L, 40L, 210L, 140L, 120L, 70L, 
    35L, 30L, 90L, 40L, 240L, 40L, 55L, 120L, 200L, 65L, 40L, 
    95L, 140L, 220L, 70L, 40L, 30L, 50L, 95L, 50L, 50L, 50L, 
    70L, 160L, 45L, 35L, 50L, 70L, 230L, 110L, 300L, 50L, 105L, 
    60L, 50L, 60L, 70L, 30L, 60L, 30L, 110L, 80L, 80L, 30L, 60L, 
    70L, 80L, 60L, 40L, 220L, 140L, 110L, 40L, 40L, 40L, 90L, 
    125L, 90L, 100L, 270L, 420L, 60L, 70L, 53L, 40L, 80L, 90L, 
    30L, 40L, 65L, 40L, 110L, 90L, 40L, 190L, 110L, 70L, 52L, 
    120L, 95L, 50L, 50L, 140L, 75L, 30L, 50L, 60L, 125L, 60L, 
    80L, 35L, 55L, 140L, 140L, 240L, 65L, 40L, 200L, 80L, 60L, 
    65L, 120L, 80L, 230L, 150L, 40L, 50L, 60L, 210L, 50L, 130L, 
    140L, 210L, 60L, 50L, 90L, 120L, 55L, 50L, 20L, 50L, 40L, 
    70L, 40L, 100L, 80L, 85L, 60L, 50L, 20L, 200L, 40L, 70L, 
    50L, 200L, 60L, 43L, 30L, 60L, 40L, 70L, 40L, 40L, 40L, 50L, 
    110L, 70L, 30L, 50L, 85L, 70L, 40L, 100L, 40L, 50L, 100L, 
    40L, 70L, 40L, 40L, 50L, 210L, 50L, 140L, 80L, 75L, 90L, 
    40L, 50L, 60L, 50L, 80L, 50L, 60L, 40L, 60L, 170L, 60L, 80L, 
    80L, 15L, 40L, 70L, 45L, 45L, 45L, 110L, 200L, 30L, 60L, 
    40L, 60L, 160L, 40L, 90L, 80L, 30L, 40L, 270L, 50L, 50L, 
    60L, 60L, 50L, 30L, 70L, 170L, 50L, 30L, 50L, 60L, 40L, 60L, 
    60L, 140L, 80L, 80L, 220L, 45L, 80L, 130L, 50L, 40L, 220L, 
    40L, 70L, 60L, 80L, 50L, 200L, 115L, 50L, 90L, 400L, 50L, 
    360L, 40L, 60L, 60L, 65L, 100L, 50L, 55L, 60L, 50L, 130L, 
    40L, 130L, 40L, 40L, 120L, 66L, 55L, 100L, 75L, 60L, 80L, 
    60L, 90L, 160L, 50L, 210L, 35L, 60L, 40L, 55L, 50L, 90L, 
    220L, 60L, 120L, 62L, 60L, 40L, 60L, 70L, 60L, 90L, 50L, 
    50L, 30L, 110L, 70L, 80L, 90L, 210L, 70L, 65L, 160L, 100L, 
    25L, 55L, 40L, 60L, 110L, 70L, 50L, 60L, 70L, 60L, 60L, 170L, 
    45L, 60L, 120L, 40L, 60L, 130L, 40L, 170L, 50L, 80L, 60L, 
    150L, 90L, 60L, 120L, 120L, 80L, 30L, 110L, 230L, 190L, 70L, 
    110L, 50L, 60L, 82L, 60L, 30L, 60L, 200L, 90L, 30L, 140L, 
    60L, 70L, 70L, 100L, 60L, 415L, 115L, 90L, 60L, 60L, 80L, 
    60L, 55L, 90L, 65L, 60L, 40L, 40L, 90L, 50L, 70L, 70L, 120L, 
    40L, 50L, 110L, 45L, 30L, 95L, 30L, 70L), width = c(310L, 
    50L, 40L, 30L, 60L, 70L, 20L, 80L, 70L, 20L, 220L, 40L, 60L, 
    30L, 230L, 110L, 20L, 40L, 25L, 60L, 240L, 90L, 30L, 130L, 
    120L, 110L, 60L, 70L, 30L, 110L, 30L, 180L, 20L, 80L, 110L, 
    310L, 40L, 10L, 80L, 160L, 134L, 30L, 20L, 40L, 20L, 230L, 
    100L, 180L, 40L, 120L, 130L, 30L, 40L, 100L, 30L, 180L, 70L, 
    110L, 170L, 40L, 30L, 50L, 30L, 40L, 30L, 50L, 80L, 50L, 
    80L, 90L, 70L, 70L, 190L, 60L, 50L, 30L, 150L, 150L, 50L, 
    80L, 30L, 40L, 130L, 390L, 60L, 130L, 400L, 200L, 110L, 30L, 
    15L, 300L, 70L, 140L, 30L, 50L, 30L, 40L, 110L, 240L, 50L, 
    90L, 70L, 20L, 40L, 100L, 50L, 30L, 30L, 130L, 40L, 70L, 
    70L, 60L, 10L, 30L, 60L, 50L, 40L, 120L, 90L, 210L, 50L, 
    20L, 100L, 100L, 110L, 100L, 100L, 80L, 120L, 80L, 5L, 40L, 
    50L, 60L, 15L, 100L, 120L, 200L, 30L, 80L, 60L, 70L, 30L, 
    30L, 20L, 50L, 50L, 60L, 15L, 80L, 60L, 130L, 40L, 60L, 30L, 
    100L, 20L, 130L, 60L, 120L, 70L, 20L, 60L, 20L, 40L, 50L, 
    15L, 120L, 60L, 50L, 300L, 40L, 30L, 25L, 70L, 130L, 30L, 
    50L, 60L, 50L, 50L, 50L, 20L, 30L, 70L, 35L, 180L, 40L, 50L, 
    70L, 40L, 70L, 50L, 20L, 40L, 40L, 40L, 40L, 50L, 20L, 30L, 
    180L, 30L, 130L, 30L, 15L, 25L, 50L, 40L, 40L, 40L, 50L, 
    170L, 20L, 50L, 20L, 50L, 110L, 30L, 90L, 15L, 50L, 40L, 
    150L, 30L, 30L, 30L, 20L, 40L, 20L, 100L, 60L, 40L, 30L, 
    30L, 140L, 40L, 50L, 120L, 150L, 100L, 70L, 300L, 30L, 60L, 
    120L, 30L, 50L, 100L, 60L, 90L, 50L, 40L, 140L, 130L, 60L, 
    60L, 70L, 200L, 30L, 40L, 50L, 20L, 20L, 20L, 80L, 35L, 70L, 
    15L, 40L, 360L, 70L, 50L, 50L, 30L, 110L, 30L, 30L, 90L, 
    50L, 30L, 70L, 40L, 110L, 70L, 40L, 150L, 100L, 40L, 40L, 
    40L, 20L, 250L, 180L, 40L, 60L, 20L, 120L, 40L, 50L, 60L, 
    260L, 110L, 30L, 30L, 40L, 100L, 50L, 50L, 100L, 150L, 190L, 
    70L, 110L, 50L, 10L, 40L, 50L, 60L, 80L, 30L, 20L, 150L, 
    70L, 25L, 30L, 40L, 50L, 30L, 50L, 210L, 40L, 100L, 30L, 
    80L, 20L, 30L, 70L, 130L, 60L, 50L, 50L, 70L, 50L, 30L, 150L, 
    130L, 110L, 50L, 40L, 80L, 90L, 40L, 40L, 40L, 40L, 200L, 
    140L, 40L, 25L, 50L, 50L, 40L, 20L, 40L, 340L, 70L, 60L, 
    50L, 20L, 80L, 60L, 25L, 260L, 20L, 15L, 40L, 30L, 300L, 
    120L, 60L, 100L, 50L, 40L, 20L, 90L, 50L, 40L, 80L, 30L, 
    40L), length = c(450L, 80L, 55L, 50L, 90L, 90L, 30L, 90L, 
    90L, 30L, 240L, 50L, 70L, 40L, 380L, 200L, 40L, 40L, 35L, 
    110L, 250L, 120L, 70L, 150L, 130L, 140L, 90L, 90L, 40L, 390L, 
    40L, 190L, 40L, 110L, 140L, 360L, 50L, 30L, 130L, 500L, 200L, 
    30L, 25L, 60L, 30L, 350L, 110L, 180L, 70L, 180L, 200L, 40L, 
    70L, 110L, 70L, 180L, 90L, 150L, 400L, 100L, 60L, 70L, 70L, 
    60L, 30L, 50L, 80L, 180L, 110L, 100L, 110L, 110L, 210L, 80L, 
    70L, 40L, 500L, 210L, 50L, 80L, 40L, 50L, 350L, 400L, 150L, 
    200L, 400L, 280L, 240L, 40L, 50L, 360L, 140L, 140L, 50L, 
    50L, 40L, 50L, 210L, 370L, 70L, 110L, 80L, 50L, 50L, 100L, 
    80L, 50L, 35L, 140L, 60L, 90L, 110L, 60L, 130L, 180L, 70L, 
    70L, 40L, 230L, 130L, 290L, 90L, 40L, 100L, 100L, 120L, 150L, 
    110L, 80L, 220L, 90L, 5L, 50L, 50L, 60L, 30L, 150L, 120L, 
    200L, 60L, 170L, 80L, 90L, 40L, 50L, 70L, 50L, 60L, 100L, 
    15L, 90L, 70L, 150L, 60L, 90L, 50L, 120L, 20L, 220L, 80L, 
    140L, 120L, 30L, 60L, 40L, 40L, 70L, 30L, 180L, 60L, 110L, 
    300L, 50L, 60L, 50L, 110L, 160L, 40L, 70L, 70L, 60L, 70L, 
    50L, 25L, 30L, 215L, 70L, 220L, 70L, 80L, 90L, 60L, 130L, 
    60L, 20L, 60L, 50L, 40L, 60L, 100L, 40L, 70L, 210L, 40L, 
    500L, 40L, 30L, 50L, 80L, 40L, 60L, 80L, 50L, 220L, 20L, 
    70L, 50L, 50L, 180L, 50L, 90L, 15L, 120L, 80L, 170L, 30L, 
    30L, 60L, 20L, 60L, 30L, 140L, 80L, 40L, 50L, 40L, 200L, 
    80L, 80L, 120L, 160L, 210L, 120L, 400L, 60L, 60L, 180L, 70L, 
    70L, 150L, 70L, 110L, 70L, 80L, 250L, 140L, 90L, 60L, 180L, 
    400L, 60L, 50L, 60L, 40L, 30L, 50L, 100L, 40L, 110L, 30L, 
    80L, 400L, 70L, 50L, 80L, 30L, 180L, 70L, 60L, 100L, 70L, 
    50L, 100L, 60L, 220L, 70L, 70L, 200L, 110L, 50L, 110L, 50L, 
    60L, 250L, 220L, 60L, 80L, 35L, 210L, 70L, 70L, 110L, 320L, 
    280L, 60L, 50L, 60L, 100L, 70L, 70L, 170L, 170L, 230L, 80L, 
    130L, 90L, 10L, 60L, 70L, 60L, 120L, 40L, 50L, 160L, 100L, 
    30L, 40L, 40L, 90L, 30L, 80L, 240L, 100L, 170L, 60L, 120L, 
    20L, 40L, 70L, 150L, 80L, 50L, 90L, 130L, 70L, 60L, 480L, 
    150L, 130L, 90L, 70L, 150L, 100L, 70L, 50L, 40L, 60L, 400L, 
    200L, 80L, 30L, 120L, 70L, 50L, 40L, 40L, 360L, 90L, 70L, 
    60L, 40L, 110L, 80L, 25L, 270L, 40L, 25L, 50L, 30L, 320L, 
    150L, 100L, 100L, 60L, 40L, 50L, 100L, 50L, 50L, 200L, 30L, 
    80L), ground = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
    2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 
    1L, 2L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 3L, 1L, 
    2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 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, 1L, 1L, 0L, 0L, 1L, 0L, 
    0L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 
    0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 
    0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 0L, 
    1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 
    0L)), .Names = c("site", "species", "aspect", "height", "width", 
    "length", "ground", "sun", "leaf", "Presence"), row.names = c(NA, 
    393L), class = "data.frame")

After model selection, I came up with the following optimal model:

model <- glm(Presence ~ site + species + aspect + length + sun + leaf, 
             data=MyData, family=binomial)

I ran the following code, based on a suggestion in one of threads on Stack Overflow:

pred <- predict(model, type="response")
windows()
  par(mfrow=c(2,2))
  for(i in names(MyData)[1:4]){
    plot(MyData[,i], pred, xlab=i, ylab="Probability")
  }
windows()
  par(mfrow=c(2,2))
  for(i in names(MyData)[5:8]){
    plot(MyData[,i], pred, xlab=i, ylab="Probability")
  }
windows(height=3.5, width=7)
  par(mfrow=c(1,2))
  for(i in names(MyData)[9:10]){
    plot(MyData[,i], pred, xlab=i, ylab="Probability")
  }

enter image description here
enter image description here
enter image description here

My questions regarding the resulting plots:

  1. How would you interpret these plots?

  2. Are the boxplots of categorical variables the actual predicted probabilities? I expect so, but I'm not sure.

  3. For the continuous variable "length", I would expect a sinusoidal curve, but that's not what I'm getting. The apparent predicted probabilities are plotted as points.

  4. The output also gives me predicted values for variables that are not even included in the final optimal model, so they should not be there.

Can someone provide some insight?

$\endgroup$
1
  • $\begingroup$ 2 - 4 are largely R coding questions (#3 has a statistical understanding component, though). #1 should definitely be on topic here, but it is very broad & unspecified. Can you clarify what about these plots you need help interpreting? $\endgroup$ Commented Mar 27, 2017 at 15:36

1 Answer 1

3
$\begingroup$

(As a side note: I get a warning that your model is overfitted when I run your code. Perhaps some of the dependent variables are combinations of the others, or presence is already used in another way in the model?)

Anyway in answer to your questions:

  1. The plots show the predicted probability of presence for each individual in your dataset on the y-axis, and one of the independent variables on the x-axis. For example, the individuals occuring on site R1b have a predicted probability of being present between roughly 0 and 0.75. Another example: you have one individual with a height of 500, and that particular individual has a predicted probability of occuring of 0 (given its other characteristics).

  2. Yes they are.

  3. That is because the predicted probabilities are based on the length (and other characteristics) in your dataset. Also because you use the plot function without specifying the plot type, the generic function plot picks the type that it thinks seems best, which is a scatter plot in this case.

  4. Well you loop over all variables in your dataset in your loop. If you want only the dependent variables you use in your model replace:

     for(i in names(MyData)){
       plot(MyData[,i], pred, xlab=i, ylab="Probability")}
    

    with

    for(i in c("site", "species", "aspect", "length", "sun", "leaf")){
      plot(MyData[,i], pred, xlab=i, ylab="Probability")}
    
$\endgroup$
2
  • $\begingroup$ Welcome to the site, @MaartenPunt. Since you're new here, you may want to take our tour, which has information for new users. $\endgroup$ Commented Mar 27, 2017 at 15:39
  • 2
    $\begingroup$ The model isn't so much overfitted as it is that the data have complete separation (eg, lots of 0s outputted by aggregate(Presence~species+aspect, MyData, mean)). If you're interested, there is a lot of good information about that phenomenon on the site categorized under the hauck-donner-effect. $\endgroup$ Commented Mar 27, 2017 at 15:47

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