How to set up the contrasts for comparison between two contrasts (ie. difference of the difference)

Suppose I have a dataset including 2 dependent variables( "x" and "z") and a response variable "y". the factor "x" has three levels: say 1, 2, and 3; the factor "z" has two levels, say "A" and "B". For a linear model (y ~ x, z, data=data), how can i then get the contrast between (B3-B1) and (A3-A1) ? or is there any way to do that?

Here is an example data for illustration.

Load the emmeans package

library(emmeans)

Load the built-in "warpbreaks" dataset

data(warpbreaks)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.