pairdiffsTransform.alldiffs | R Documentation |
alldiffs.object
.Predictions of differences and their error intervals are formed for two levels of
a factor, the pairs.factor
. For each pair of a level of the
pairs.factor
in numerator.levels
with a level in
denominator.levels
, an alldiffs.object
is formed that
contains the differences between predictions with this pair of levels for all of
the combinations of the levels of the other factors in the classify
of the
alldiffs.object
. These prediction differences are obtained using
linTransform
by forming a suitable contrast matrix to specify
the linear.transformation
. This function has the advantage that the
factors indexing the differences are included in the components of the
alldiffs.object
s.
If pairwise = TRUE
, all pairwise differences between the
linear transforms of the predictions
, their standard errors,
p-values and LSD statistics are computed as using
allDifferences.data.frame
.
This adds them to the alldiffs.object
as additional
list
components named differences
, sed
,
p.differences
and LSD
.
The printing of the components produced is controlled by the
tables
argument. The order of plotting the levels of
one of the factors indexing the predictions can be modified
and is achieved using sort.alldiffs
.
## S3 method for class 'alldiffs'
pairdiffsTransform(alldiffs.obj, pairs.factor, first.levels, second.levels,
Vmatrix = FALSE, error.intervals = "Confidence",
avsed.tolerance = 0.25, accuracy.threshold = NA,
LSDtype = "overall", LSDsupplied = NULL, LSDby = NULL,
LSDstatistic = "mean", LSDaccuracy = "maxAbsDeviation",
response = NULL, response.title = NULL, tables = "all",
pairwise = TRUE, alpha = 0.05, ...)
alldiffs.obj |
An |
pairs.factor |
A |
first.levels |
A |
second.levels |
A |
Vmatrix |
A |
error.intervals |
A |
avsed.tolerance |
A
|
accuracy.threshold |
A |
LSDtype |
A See |
LSDsupplied |
A |
LSDby |
A |
LSDstatistic |
A |
LSDaccuracy |
A |
response |
A |
response.title |
A |
tables |
A |
pairwise |
A |
alpha |
A |
... |
further arguments passed to |
A list
of alldiffs.object
s with a component for each combination
of a first.levels
with a second.levels
. The name of a component will be
a level from first.levels
combined with a level from second.levels
,
separated by a comma. If the predictions
in the supplied alldiffs.object
are based on a response
that was transformed, each alldiffs.object
in the list
will include a backtransforms
component that contains
a column labelled backtransformed.predictions
, along with the backtransforms of
the nominated error.intervals
. The predictions
and backtransforms
components in an alldiffs.object
will be indexed by the variables in the
classify
of alldiffs.obj
, except that the pairs.factor
is omitted.
If the transformation was the logarithmic transformation, these
backtransformed.predictions
are predicted ratios of the untransformed response
.
If sortFactor
attribute is set and is not the
ratio.factor
, the predictions and, if present, their backtransforms will be sorted using
the sortOrder
attribute of the alldiffs.object
,
and both sortFactor
and sortOrder
will be set as attributes to the object.
Chris Brien
linTransform
, ratioTransform
, predictPlus.asreml
,
as.alldiffs
, print.alldiffs
,
sort.alldiffs
, subset.alldiffs
,
allDifferences.data.frame
,
redoErrorIntervals.alldiffs
,
recalcLSD.alldiffs
, pickLSDstatistics.alldiffs
,
predictPresent.asreml
,
plotPredictions.data.frame
,
as.Date
, predict.asreml
#### Form the differences for log(RGR) for Salinity
load(system.file("extdata", "testDiffs.rda", package = "asremlPlus", mustWork = TRUE))
#### For the ratios for Cl per WU Temperature - use backtransforms of log-predictions
Preds.ratio.ClUp <- pairdiffsTransform(diffs.ClUp,
pairs.factor = "Temperature",
first.levels = "Hot",
second.levels = "Cool",
error.intervals = "halfLeast",
tables = "backtransforms") #Backtransforms are ratios
#### Form the differences for Nitrogen compared to no Nitrogen
data("Oats.dat")
## Not run:
m1.asr <- asreml(Yield ~ Nitrogen*Variety,
random=~Blocks/Wplots,
data=Oats.dat)
current.asrt <- as.asrtests(m1.asr)
wald.tab <- current.asrt$wald.tab
Var.diffs <- predictPlus(m1.asr, classify="Nitrogen:Variety", pairwise = TRUE,
Vmatrix = TRUE, error.intervals = "halfLeast",
LSDtype = "factor", LSDby = "Variety",
wald.tab = wald.tab)
## End(Not run)
## Use lme4 and emmmeans to get predictions and associated statistics
if (requireNamespace("lmerTest", quietly = TRUE) &
requireNamespace("emmeans", quietly = TRUE))
{
m1.lmer <- lmerTest::lmer(Yield ~ Nitrogen*Variety + (1|Blocks/Wplots),
data=Oats.dat)
## Set up a wald.tab
int <- as.data.frame(rbind(rep(NA,4)))
rownames(int) <- "(Intercept)"
wald.tab <- anova(m1.lmer, ddf = "Kenward", type = 1)[,3:6]
names(wald.tab) <- names(int) <- c("Df", "denDF", "F.inc", "Pr")
wald.tab <- rbind(int, wald.tab)
#Get predictions
Var.emm <- emmeans::emmeans(m1.lmer, specs = ~ Nitrogen:Variety)
Var.preds <- summary(Var.emm)
## Modify Var.preds to be compatible with a predictions.frame
Var.preds <- as.predictions.frame(Var.preds, predictions = "emmean",
se = "SE", interval.type = "CI",
interval.names = c("lower.CL", "upper.CL"))
Var.vcov <- vcov(Var.emm)
Var.sed <- NULL
den.df <- wald.tab[match("Variety", rownames(wald.tab)), "denDF"]
#Create alldiffs object
Var.diffs <- as.alldiffs(predictions = Var.preds,
sed = Var.sed, vcov = Var.vcov,
classify = "Nitrogen:Variety", response = "Yield", tdf = den.df)
}
if (exists("Var.diffs"))
Preds.diffs.OatsN <- pairdiffsTransform(alldiffs.obj = Var.diffs,
pairs.factor = "Nitrogen",
first.levels = c("0.2","0.4","0.6"),
second.levels = "0", error.intervals = "halfLeast",
tables = "none")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.