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*]