First off, in base R, I have only dabbled with the ordered factor contrasts so don't know them well enough to give reliable advice about how to interpret them. That being said, there are two ways to apply them with MAST.
First, you can set the contrasts
attribute to the column of interest:
library(MAST)
data(vbetaFA)
table(colData(vbetaFA)$Time)
# 0 3 6 12
# 91 94 94 177
contrasts(colData(vbetaFA)$Time) = 'contr.poly'
zz = zlm(~Time, sca = vbetaFA)
summary(zz)
[Note: AFAIK, you need evenly spaced factor levels for the polynomial contrasts to be interpretable.]
Second, you can use dummy coding, and then cook up whatever contrast you like to test with Hypothesis
:
contrasts(colData(vbetaFA)$Time) = 'contr.treatment'
zz = zlm(~Time+0, sca = vbetaFA)
cntr1 = Hypothesis("Time0-Time3")
cntr2 = Hypothesis("2*Time6-Time0-Time3")
lrTest(zz, cntr1)
lrTest(zz, cntr2)
Although testing is relatively easy in this case, there's some functionality missing to easily derive the coefficient estimates.
Thank you for the reply, Andrew. Since ordered factors don't seem to be used much with MAST, is there another way you might suggest modeling dose-response data? Would it make sense just to use a numeric value?
Our goal is to support any model that you can run with `lm`. Using the numeric values for your ordered factor corresponds to a very particular model: it will estimate the linear effect of dose. That is a restriction from the factor model, which allows the mean function to follow *any* effect of dose. The "ordered factor" contrasts are just one way of parametrizing this unrestricted mean function.
Without knowing your scientific question and experimental design, I can't really say much more. Normally I start with restricted models, that I am sure I understand, and then consider expanding to more general models.
None of what I wrote above is particular to the two-part models that MAST implements, so perhaps your question may not actually lie with MAST in particular? I recommend "Modern Applied Statistics with S" chapter 5 as a good general reference for linear modeling and ANOVA in R.