Writing Interaction Terms Using occu()

286 views
Skip to first unread message

Joseph Miller

unread,
Apr 14, 2021, 7:20:47 AM4/14/21
to unmarked
Greetings,

I am attempting to model single season occupancy of an increasingly rare species of minnow. While building my models I wanted to include some interactions between variables. I wanted to have an interaction between Saline (A categorical variable 0 or 1 that indicates the river system) and the Average depth (continuous variable) i.e. I'm interested in seeing how depth may have a different influence on occupancy in two different rivers. I've seen multiple approaches in doing this, and some appear to give me different output. Any input on what the best approach would be?

Method 1:

occu(formula = ~1 ~ Saline * Avgdepth, data = umf)

Method 2:

occu(formula = ~1 ~ Saline:Avgdepth, data = umf)

Method 3:

occu(formula = ~1 ~ Saline*Avgdepth-1-Avgdepth, data = umf)

Or Alternatively, in Exercises in Occupancy Estimation and Modeling; Donovan and Hines 2007, They would simply multiply the standardized average depth by the categorical Variable (0 or 1). I've attached a screenshot of Donovan and Hine (2007) for added clarification (In this case Patch size would be analogous to Average depth and Habitat 1 would be analogous to Saline or river system)

Any input on the most appropriate method would be greatly appreciated.

Thanks,

- Joe

Joseph Miller

unread,
Apr 14, 2021, 12:44:37 PM4/14/21
to unmarked
I realize I for got to attach the screenshot.Donovan and Hines.JPG

Marc J. Mazerolle

unread,
Apr 14, 2021, 4:07:42 PM4/14/21
to unma...@googlegroups.com
Hi Joseph,

If you want to understand what is happening when you specify the model
differently in the formula, you should look into model.matrix( ). The
function returns the design matrix of your model and illustrates which
parameters are estimated.

Keep in mind that an interaction term between two variables is just the
product of these two variables. Thus, manually creating an interaction
variable by multiplying two variables (A and B) is equivalent to
including "A:B" in your formula.

##create bogus data for this example
##binary variable
Saline <- rep(c(0, 1), each = 5)
##numeric variable
AvgDepth <- rnorm(n = 10, mean = 20, sd = 1.3)

##model where each group has different intercept and different slopes:
##model parameterized as difference between intercepts vs ref level
##and difference of slopes vs slope of reference level
model.matrix(~ Saline*AvgDepth)
##same as model.matrix(~ Saline + AvgDepth + Saline:AvgDepth)

##model where all groups share common intercept,
##but each group has different slopes:
model.matrix(~ Saline:AvgDepth)

##model where each group has different intercept and different slopes:
##parameterized as intercepts and slopes for each group
model.matrix(~ Saline*Avgdepth-1-Avgdepth)
##compare with model.matrix(~ Saline*AvgDepth) above

As to which model or parameterization is best, it ultimately depends on
the data you have (limitations), the presence of parameters on
boundaries, and your hypotheses.

If this is still unclear, then I suggest you look into textbooks
dealing with classic analysis of covariance (ANCOVA). There is nothing
better than trying examples with lm( ) and rebuilding the estimates
from differences of intercepts or slopes to understand how model
parameterizations work. A quick clue that two parameterizations of your
model are equivalent is when you get identical log-likelihoods for both
models.

Hope it helps,

Marc
--

-------- Message initial --------
De: Joseph Miller <mill...@gmail.com>
Répondre à: unma...@googlegroups.com
À: unmarked <unma...@googlegroups.com>
Objet: [unmarked] Writing Interaction Terms Using occu()
Date: Tue, 13 Apr 2021 16:47:29 -0700

[Externe UL*]

Joseph Miller

unread,
Apr 21, 2021, 9:58:02 AM4/21/21
to unmarked
Marc,

Sorry for the delayed response, I got busy for a minute there.

I appreciate your response, it was extremely helpful.

- Joe

Reply all
Reply to author
Forward
0 new messages