4
$\begingroup$

I am working in program R. I am modeling the incidence of flight in a seabird in relation to distance to the nearest ship (potential disturbance, range = 0 to 74 km from the bird). 1= flight during observation, 0 = no flight. The bird does fly with some unknown probability when no ships are present or really "far" away. I am trying to find this really far distance and associated probability of flight using binary logistic regression.

Model = Flight ~ ship distance. Other variables were explored but fell out with stepwise selection.

During exploratory analysis I truncated the data down only looking at smaller distances from the ship (20, 15, 10 km). These models are highly significant and predict that as the ship gets closer the probability of flight increases. However when I include all the data (out to 74 km) the intercept is significant (and predicts the true % of observed flight events) but the slope term is non-significant.

Can I use a weighting scheme to give more weight to observations when the ship was closer?

Thanks.

Edit: I am working through the suggestions made by @Scortchi and @Underminer. Here is a plot of a loess smooth on the observed data to better help visualize the pattern.

Loess smooth of probability of flight as a function of distance to nearest ship

The distance to the ship data does not discriminate between approaching ships and departing ships it is just a straight line measure to the nearest ship. The dip in the probability of flight at 8.5 I believe can be attributed to "unaffected" birds that did not fly as the ship passed by them. So as the ship departs and gets further from the observation site we were more like to be observing birds that for whatever reason did not fly when the ship passed and are less likely to fly for "naturally occurring" reason. As additional birds fill back into the observation area the "baseline" flushing rate is resumed and birds start to fly at "normal" probabilities.

$\endgroup$
  • 2
    $\begingroup$ Represent distance with a polynomial or restricted cubic spline rather than with a single linear term. $\endgroup$ – Scortchi - Reinstate Monica Jan 30 '14 at 20:50
  • $\begingroup$ Also perhaps search for "stepwise" here, or read this paper & consider whether you're sure it's really solving a problem you have. $\endgroup$ – Scortchi - Reinstate Monica Jan 30 '14 at 23:27
  • 1
    $\begingroup$ Thanks for posting the data plot, it certainly helps to visualize the data. As far as the Loess plot, I think it may be overfitting the data. Trying to explain to a scientist why a bird is approximately twice more likely to fly when a boat is 60km away than when the boat is 8km away would be difficult. Perhaps you could try increasing the smoothing parameter. $\endgroup$ – Underminer Jan 31 '14 at 18:04
  • 1
    $\begingroup$ Could choose the smoothing bandwidth using cross-validation. What's interesting is determining whether the dip's real - an artefact of the experimental protocol or an interesting fact about bird behaviour - or just overfitting, as @Underminer suggests it might be. $\endgroup$ – Scortchi - Reinstate Monica Jan 31 '14 at 19:39
  • $\begingroup$ I agree with @Scortchi; choosing the smoothing bandwidth with cross-validation sounds like a good idea. $\endgroup$ – Underminer Jan 31 '14 at 19:42
4
$\begingroup$

Weighting observations differently is appropriate when some measurements are made with greater precision than others.

In this case the problem is much more likely with the functional form of your model: assuming a linear relationship between the logit of flight probability & ship distance. Use a model that's suggested by theory, or one that's flexible enough to incorporate curvature: polynomials & restricted cubic splines are the standard choices; mine would probably be splines for the situation you described

| cite | improve this answer | |
$\endgroup$
2
$\begingroup$

Based on what you have told me of the study, I believe it would be perfectly acceptable to model close ship distances (truncate the data as you have done) separately from far ships if it appears the ships have no effect on the birds if they are too far away. You could do what is called broken-stick regression, also known as segmented or piecewise regression.

I would suggest plotting the response by distance, and if there appears to be a distinct difference in the model when ship distance is high compared to when the ship distance is low, this provides good evidence using broken-stick regression. I have a hunch (without seeing your data) that birds are not affected by far away ships at all (because they cannot even sense the ships), but may nicely fit the logistic regression as ships get closer. This would explain why the logistic regression coefficient was insignificant when all distances were included, yet it was significant when fit on the truncated data (see example scenario below). If the data support this idea, you could find the breakpoint and then fit both sides separately.

The diagram below is a simple example of what I think your data may look like. The solid dots represent the data (Fly/notFly vs Distance). I then noticed that it appears the close Distances are more likely to result in Fly, but high Distances seem to have a constant (and low) probability of Fly as if they are unaffected by Distance. So I modeled the Distances <40 using logistic (blue predicted probabilities), and considered anything after 40 to be a flat line at the last predicted probability (red predicted probabilities). This makes the inherent assumption that after a certain point, distance does not matter at all (seems reasonable enough to me).

enter image description here

Logistic regression performed on all distances gave the following fit (notice Distance is not significant):

enter image description here

Logistic regression performed on Distance<40 gave the following fit (notice Distance is significant now):

enter image description here

Even if you do down weight the far distance observations, you would in effect be stating that you believe the far away cases are less important (because they don't fit the model), so you might as well model them separately.

Here is the R code I used to generate the example if you are interested:

# Generate made up data
Fly = c(1,1,1,0,1,1,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1)
Distance = c(1:20, 20+2*(1:10), 40+4*(1:10))
plot(Fly ~ Distance)

# Fit all distances using logistic regression
fitAll = glm(Fly ~ Distance, family = binomial) 
summary(fitAll)

# Fit 30 closest points (Distance <40) only
fitClose = glm(Fly[1:30] ~ Distance[1:30], family = binomial) 
summary(fitClose)

# Plot logistic regression predicted probabilities for Distance <40
points(fitClose$fitted ~ Distance[1:30], col = "blue")

# Plot second regression probabilities for Distance >40
points(rep(fitClose$fitted[30],10) ~ Distance[31:40], col = "red")
| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ As a side note, the fit seemed fairly robust to the choice of the breakpoint used. $\endgroup$ – Underminer Jan 30 '14 at 21:13
  • $\begingroup$ (+1) I'd rather have a model with no discontinuities & not have to choose the breakpoint in any data-dependent way, but you've explained the issues well & that's a sensible approach. $\endgroup$ – Scortchi - Reinstate Monica Jan 30 '14 at 21:22
  • $\begingroup$ @Scortchi, I agree choosing the breakpoint could potentially be a problem. Perhaps estimating/justifying it via cross-validation would be more acceptable. $\endgroup$ – Underminer Jan 30 '14 at 21:36
  • $\begingroup$ I will take a look at a polynomial term, cubic splines and the broken stick method and report back. Thanks. $\endgroup$ – marcellt Jan 30 '14 at 21:59
  • $\begingroup$ @marcellt: Good introduction to regression splines here. And some discussion of smoothing with loess, which I forgot to mention, & which is also useful for exploration. $\endgroup$ – Scortchi - Reinstate Monica Jan 30 '14 at 23:14

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.