allDifferences.data.frame | R Documentation |
Uses supplied predictions and standard errors of pairwise differences,
or the variance matrix of predictions to form, in an
alldiffs.object
, for those components not already present,
(i) a table of all pairwise differences of the predictions,
(ii) the p-value of each pairwise difference, and
(iii) the minimum, mean, maximum and accuracy of LSD values.
Predictions that are aliased (or inestimable) are removed from the
predictions
component of the alldiffs.object
and
standard errors of differences involving them are removed from the sed
component.
If necessary, the order of the columns of the variables in the predictions
component are changed to be the initial columns of the predictions.frame
and to match their order in the classify
. Also, the rows of predictions
component are ordered so that they are in standard order for the variables in the
classify
. That is, the values of the last variable change with every row,
those of the second-last variable only change after all the values of the last
variable have been traversed; in general, the values of a variable are the same for
all the combinations of the values to the variables to its right in the
classify
. The sortFactor
or sortOrder
arguments can be used
to order of the values for the classify
variables, which is achieved using
sort.alldiffs
.
Each p-value is computed as the probability of a t-statistic as large as or larger
than the absolute value of the observed difference divided by its standard error. The
p-values are stored in the p.differences
component. The degrees of freedom of
the t-distribution is the degrees of freedom stored in the tdf
attribute of
the alldiffs.object
. This t-distribution is also used in calculating
the LSD statistics stored in the LSD
component of the alldiffs.object
.
## S3 method for class 'data.frame'
allDifferences(predictions, classify, vcov = NULL,
differences = NULL, p.differences = NULL, sed = NULL,
LSD = NULL, LSDtype = "overall", LSDsupplied = NULL,
LSDby = NULL, LSDstatistic = "mean",
LSDaccuracy = "maxAbsDeviation",
retain.zeroLSDs = FALSE,
zero.tolerance = .Machine$double.eps ^ 0.5,
backtransforms = NULL,
response = NULL, response.title = NULL,
term = NULL, tdf = NULL,
x.num = NULL, x.fac = NULL,
level.length = NA,
pairwise = TRUE, alpha = 0.05,
transform.power = 1, offset = 0, scale = 1,
transform.function = "identity",
inestimable.rm = TRUE,
sortFactor = NULL, sortParallelToCombo = NULL,
sortNestingFactor = NULL, sortOrder = NULL,
decreasing = FALSE, ...)
predictions |
A |
classify |
A |
vcov |
A |
differences |
A |
p.differences |
A |
sed |
A |
LSD |
An |
LSDtype |
A See |
LSDsupplied |
A |
LSDby |
A |
LSDstatistic |
A |
LSDaccuracy |
A |
retain.zeroLSDs |
A |
zero.tolerance |
A |
backtransforms |
A |
response |
A |
response.title |
A |
term |
A |
tdf |
an |
x.num |
A |
x.fac |
A |
level.length |
The maximum number of characters from the levels of factors to use in the row and column labels of the tables of pairwise differences and their p-values and standard errors. |
pairwise |
A logical indicating whether all pairwise differences of the
|
alpha |
A |
transform.power |
A |
offset |
A |
scale |
A |
transform.function |
A |
inestimable.rm |
A |
sortFactor |
A |
sortParallelToCombo |
A |
sortNestingFactor |
A |
sortOrder |
A The following creates a |
decreasing |
A |
... |
provision for passsing arguments to functions called internally - not used at present. |
An alldiffs.object
with components
predictions
, vcov
, differences
, p.differences
sed
, and LSD
.
The name of the response
, the response.title
,
the term
, the classify
, tdf
, alpha
, sortFactor
and the sortOrder
will be set as attributes to the object.
Note that the classify
in an alldiffs.object
is based on the
variables indexing the predictions, which may differ from the
classify
used to obtain the original predictions (for example,
when the alldiffs.object
s stores a linear transformation of predictions.
Also, see predictPlus.asreml
for more information.
Chris Brien
asremlPlus-package
, as.alldiffs
, as.predictions.frame
,
sort.alldiffs
, subset.alldiffs
,
print.alldiffs
, renewClassify.alldiffs
,
redoErrorIntervals.alldiffs
,
recalcLSD.alldiffs
, pickLSDstatistics.alldiffs
,
plotPredictions.data.frame
,
predictPlus.asreml
, predictPresent.asreml
data(Oats.dat)
## Use asreml to get predictions and associated statistics
## Not run:
m1.asr <- asreml(Yield ~ Nitrogen*Variety,
random=~Blocks/Wplots,
data=Oats.dat)
current.asrt <- as.asrtests(m1.asr)
Var.pred <- asreml::predict.asreml(m1.asr, classify="Nitrogen:Variety",
sed=TRUE)
if (getASRemlVersionLoaded(nchar = 1) == "3")
Var.pred <- Var.pred$predictions
Var.preds <- Var.pred$pvals
Var.sed <- Var.pred$sed
Var.vcov <- NULL
wald.tab <- current.asrt$wald.tab
den.df <- wald.tab[match("Variety", rownames(wald.tab)), "denDF"]
## End(Not run)
## Use lmerTest 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)
Var.emm <- emmeans::emmeans(m1.lmer, specs = ~ Nitrogen:Variety)
Var.preds <- summary(Var.emm)
den.df <- min(Var.preds$df)
## 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
}
## Use the predictions obtained with either asreml or lmerTest
if (exists("Var.preds"))
{
## Order the Varieties in decreasing order for the predictions values in the
## first N level
Var.diffs <- allDifferences(predictions = Var.preds,
classify = "Nitrogen:Variety",
sed = Var.sed, vcov = Var.vcov, tdf = den.df,
sortFactor = "Variety", decreasing = TRUE)
print.alldiffs(Var.diffs, which="differences")
## Change the order of the factors in the alldiffs object and reorder components
Var.reord.diffs <- allDifferences(predictions = Var.preds,
classify = "Variety:Nitrogen",
sed = Var.sed, vcov = Var.vcov, tdf = den.df)
print.alldiffs(Var.reord.diffs, which="predictions")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.