alldiffs.object {asremlPlus} | R Documentation |
Description of an alldiffs object
Description
An object of S3-class alldiffs
that stores the predictions for a model,
along with supplied statistics for all pairwise differences. While
alldiffs.object
can be constructed by defining a list
with
the appropriate components, it can be formed by passing the components to
as.alldiffs
, or from a predictions
data.frame
using
allDifferences.data.frame
.
as.alldiffs
is function that assembles an object of this class from
supplied components.
is.alldiffs
is the membership function for this class; it tests
that an object is of class alldiffs
.
validAlldiffs(object)
can be used to test the validity of an object
with this class.
allDifferences.data.frame
is the function that constructs an
object of this class by calculating components from statistics supplied via
its arguments and then using as.alldiffs
to make the object.
Value
A list
of class alldiffs
containing the following components:
predictions
, vcov
, differences
,
p.differences
, sed
, LSD
and backtransforms
.
Except for predictions
, the components are optional and can be set
to NULL
.
An alldiffs.object
also has attributes response
,
response.title
, term
, classify
, tdf
, alpha
,
sortFactor
and sortOrder
, which may be set to NULL
.
The details of the components are as follows:
-
predictions
: Apredictions.frame
, being adata.frame
beginning with the variables classifying the predictions, in the same order as in theclassify
, and also containing columns namedpredicted.value
,standard.error
andest.status
; each row contains a single predicted value. The number of rows should equal the number of unique combinations of theclassify
variables and will be in standard order for theclassify
variables. 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 theclassify
.The
data.frame
may also include columns for the lower and upper values of error intervals, either standard error, confidence or half-LSD intervals. The names of these columns will consist of three parts separated by full stops: 1) the first part will belower
orupper
; 2) the second part will be one ofConfidence
,StandardError
orhalfLeastSignificant
; 3) the third component will belimits
.Note that the names
standard.error
andest.status
have been changed tostd.error
andstatus
in thepvals
component produced byasreml-R4
; if the new names are in thedata.frame
supplied topredictions
, they will be returned to the previous names. -
differences
: Amatrix
containing all pairwise differences between the predictions; it should have the same number of rows and columns as there are rows inpredictions
. -
p.differences
: Amatrix
containing p-values for all pairwise differences between the predictions; each p-value is computed as the probability of a t-statistic as large as or larger than the observed difference divided by its standard error. The degrees of freedom of the t distribution for computing it are computed as the denominator degrees of freedom of the F value for the fixed term, if available; otherwise, the degrees of freedom stored in the attributetdf
are used; the matrix should be of the same size as that fordifferences
. -
sed
: Amatrix
containing the standard errors of all pairwise differences between the predictions; they are used in computing the p-values inp.differences
. -
vcov
: Amatrix
containing the variance matrix of the predictions; it is used in computing the variance of linear transformations of the predictions. -
LSD
: AnLSD.frame
containing (i)c
, the number of pairwise predictions comparisons for each LSD value and the mean, minimum, maximum and assigned LSD, (ii) the columnaccuracyLSD
that gives a measure of the accuracy of the assigned LSD. given the variation in LSD values, and (iii) the columnsfalse.pos
andfalse.neg
that contain the number of false positives and negatives if theassignedLSD
value(s) is(are) used to determine the significance of the pairwise predictions differences. The LSD values in theassignedLSD
column is used to determine the significance of pairwise differences that involve predictions for the combination of levels given by a row name. The value in theassignedLSD
column is specified using theLSDstatistic
argument. -
backtransforms
: When the response values have been transformed for analysis, adata.frame
containing the backtransformed values of the predicted values is added to thealldiffs.object
. Thisdata.frame
is consistent with thepredictions
component, except that the column namedpredicted.value
is replaced by one calledbacktransformed.predictions
. Anyerror.interval
values will also be the backtransformed values. Each row contains a single predicted value.
The details of the attributes
of an alldiffs.object
are:
-
response
: Acharacter
specifying the response variable for the predictions. -
response.title
: Acharacter
specifying the title for the response variable for the predictions. -
term
: Acharacter
giving the variables that define the term that was fitted usingasreml
and that corresponds toclassify
. It is often the same asclassify
. -
classify
: Acharacter
giving the variables that define the margins of the multiway table used in the prediction. Multiway tables are specified by forming an interaction type term from the classifying variables, that is, separating the variable names with the:
operator. -
tdf
: Aninteger
specifying the degrees of freedom of the standard error. It is used as the degrees of freedom for the t-distribution on which p-values and confidence intervals are based. -
alpha
: Aninteger
specifying the significance level. It is used as the significance level calculating LSDs. -
LSDtype
: If theLSD
component is notNULL
thenLSDtype
is added as an attribute. Acharacter
nominating the type of grouping of seds to be used in combining LSDs. -
LSDby
: If theLSD
component is notNULL
thenLSDby
is added as an attribute. Acharacter
vector
containing the names of the factors and numerics within whose combinations the LSDs are to be summarized. -
LSDstatistic
: If theLSD
component is notNULL
thenLSDstatistic
is added as an attribute. Acharacter
nominating what statistic to use in summarizing a set of LSDs. -
LSDaccuracy
: If theLSD
component is notNULL
thenLSDaccuracy
is added as an attribute. Acharacter
nominating the method of calculating a measure of the accuracy of the LSDs stored in theassignedLSD
column of theLSD.frame
. -
sortFactor
:factor
that indexes the set of predicted values that determined the sorting of the components. -
sortOrder
: Acharacter
vector that is the same length as the number of levels forsortFactor
in thepredictions
component of thealldiffs.object
. It specifies the order of the levels in the reordered components of thealldiffs.object
.
The following creates a sortOrder
vector levs
for factor
f
based on the values in x
:
levs <- levels(f)[order(x)]
.
See predictPlus.asreml
for more information.
Author(s)
Chris Brien
See Also
is.alldiffs
, as.alldiffs
, validAlldiffs
, allDifferences.data.frame
Examples
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
## 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"))
{
## Form an all.diffs object
Var.diffs <- as.alldiffs(predictions = Var.preds, classify = "Nitrogen:Variety",
sed = Var.sed, vcov = Var.vcov, tdf = den.df)
## Check the class and validity of the alldiffs object
is.alldiffs(Var.diffs)
validAlldiffs(Var.diffs)
}