subset.alldiffs | R Documentation |
alldiffs.object
according to the supplied condition.Subsets each of the components of an alldiffs.object
. The subset is
determined by applying the condition to the prediction
component to
determine which of its rows are to be included in the subset. Then, if present,
this subset is applied to the rows of backtransforms
and to the rows
and columns of differences
, p.differences
and sed
components. In addition, if sed
is present, recalcLSD.alldiffs
is called to recalculate the values in the LSD.frame
stored in the
LSD
component, with any arguments supplied via the ...
argument passed ot it.
The select
argument of subset
is not implemented, but can be
achieved for variables in the classify
using the rmClassifyVars
argument.
## S3 method for class 'alldiffs'
subset(x, subset = rep(TRUE, nrow(x$predictions)),
rmClassifyVars = NULL, ...)
x |
An |
subset |
A |
rmClassifyVars |
A |
... |
further arguments passed to |
An alldiffs.object
with the following components of the supplied
alldiffs.object
subsetted, if present in the original object:
predictions
, vcov
, backtransforms
, differences
,
p.differences
and sed
. In addition, if sed
is present, the
LSD.frame
in the LSD
component will be recalculated.
Chris Brien
as.alldiffs
, allDifferences.data.frame
,
print.alldiffs
, sort.alldiffs
,
redoErrorIntervals.alldiffs
, recalcLSD.alldiffs
,
predictPlus.asreml
, predictPresent.asreml
data(WaterRunoff.dat)
##Use asreml to get predictions and associated statistics
## Not run:
asreml.options(keep.order = TRUE) #required for asreml-R4 only
current.asr <- asreml(fixed = pH ~ Benches + (Sources * (Type + Species)),
random = ~ Benches:MainPlots,
keep.order=TRUE, data= WaterRunoff.dat)
current.asrt <- as.asrtests(current.asr, NULL, NULL)
TS.diffs <- predictPlus.asreml(classify = "Sources:Type",
asreml.obj = current.asr, tables = "none",
wald.tab = current.asrt$wald.tab,
present = c("Type","Species","Sources"))
## End(Not run)
## Use lmeTest and emmmeans to get predictions and associated statistics
if (requireNamespace("lmerTest", quietly = TRUE) &
requireNamespace("emmeans", quietly = TRUE))
{
m1.lmer <- lmerTest::lmer(pH ~ Benches + (Sources * (Type + Species)) +
(1|Benches:MainPlots),
data=na.omit(WaterRunoff.dat))
TS.emm <- emmeans::emmeans(m1.lmer, specs = ~ Sources:Type)
TS.preds <- summary(TS.emm)
den.df <- min(TS.preds$df, na.rm = TRUE)
## Modify TS.preds to be compatible with a predictions.frame
TS.preds <- as.predictions.frame(TS.preds, predictions = "emmean",
se = "SE", interval.type = "CI",
interval.names = c("lower.CL", "upper.CL"))
## Form an all.diffs object and check its validity
TS.vcov <- vcov(TS.emm)
TS.diffs <- allDifferences(predictions = TS.preds, classify = "Sources:Type",
vcov = TS.vcov, tdf = den.df)
validAlldiffs(TS.diffs)
}
## Plot p-values for predictions obtained using asreml or lmerTest
if (exists("TS.diffs"))
{
##Use subset.alldiffs to select a subset of the alldiffs object
TS.diffs.subs <- subset(TS.diffs,
subset = grepl("R", Sources, fixed = TRUE) &
Type %in% c("Control","Medicinal"))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.