[R] multiple instances of predictor variable per model

Sima Usvyatsov ghiaco at gmail.com
Thu Dec 14 13:23:43 CET 2017


I’m running a model on animal behavior in response to shipping. In most
cases, there is only one ship in the study area at one time. Ship length,
distance from the animals, speed, angle from animals, and ship direction
(as east/west bound) are among shipping-related covariates (with multiple
interactions).

The tricky part is that sometimes there are 2 ships in the area. I could
add all the same covariates, but doubled-up for the second ship. However,
this really hurts convergence. And - conceptually - why would ship length
affect the animals differently between ship 1 and ship 2? I would think
that animals would react similarly to both ships (and the effect would just
add up), so I don’t want the model to estimate two covariates that I think
are the same. And if I had 5 ships instead of 2, those dfs would really
rack up.

Note that I can’t just double the vessel values, since their speeds,
directions, lengths, etc all differ.

Here's a little mock data set for 3 surveys - 2 have a single ship, and 1
has two ships. Note that each survey is only done once, so if there are 2
ships (or more), the number of animals (and all other survey-related info)
is just copied over on another line

df <- data.frame(Survey = c(1, 1, 2, 3), NAnimals = c(10, 10, 1, 0),
Vessel = c("A", "B", "C", "D"), VesselLength = c(20, 50, 40, 70),
VesselSpeed = c(10, 5, 4, 5), Direction = c("West", "East", "West", "West"))

Disclaimer: this is a crosspost from here (
https://stats.stackexchange.com/questions/318667/multiple-instances-of-predictor-variables
).

Many thanks.

	[[alternative HTML version deleted]]



More information about the R-help mailing list