contrast sum with interaction
Not specifically a glmmTMB question, but maybe someone here can help.
I'd like to use a contrast sum constraint with an interaction between a
continuous and discrete variable, but I can't seem to get model.matrix to
do what I want.
The situation is that I want a categorical variable that is coded with a
sum constraint but only included in some rows of the model matrix (which is
why I am using the interaction with the continuous 0/1 valued variable).
Maybe there is a better way to code this.
Here is an example of what I mean:
dat<-data.frame(y=1,cont.var=rep(0:1,each=2),disc.var=rep(c("a","b"),2));
model.matrix(y~ cont.var : disc.var ,data=dat,contrasts.arg =
list(disc.var="contr.sum"))
What I'd like in this example is a model matrix with two columns, where the
second column has 0 when cont.var =0, 1 when cont.var=1 & disc.var = a, and
-1 when cont.var=1 and disc.var=b.
Thanks so much for your help! -Mark
Mark Sorel Doctoral Student Washington Cooperative Fish and Wildlife Research Unit School of Aquatic and Fishery Sciences University of Washington Cell: 607-351-7352 He/ him/ his *The University of Washington acknowledges the Coast Salish peoples of this land, the land which touches the shared waters of all tribes and bands within the Suquamish, Tulalip and Muckleshoot nations*. [[alternative HTML version deleted]]