[R-sig-ME] contrast sum with interaction

Mark Sorel m@rk@6 @end|ng |rom uw@edu
Thu Jul 15 20:22:52 CEST 2021

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:

model.matrix(y~ cont.var  : disc.var  ,data=dat,contrasts.arg =

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

More information about the R-sig-mixed-models mailing list