linTransform.alldiffs {asremlPlus}  R Documentation 
alldiffs.object
.Effects the linear transformation of the predictions in the
supplied alldiffs.object
, the transformation being specified
by a matrix
or a formula
. The values of
the transformed values are stored in an alldiffs.object
.
A matrix
might be a contrast matrix
or
a matrix
of weights for the levels of a
factor
used to obtain the weighted average over
the levels of that factor
. A formula
gives
rise to a projection matrix
that linearly transforms
the predictions so that they conform to the model specified by the
formula
, this model being a submodel of that inherent
in the classify
.
If pairwise = TRUE
, all pairwise differences between the
linear transforms of the predictions
, their standard errors,
pvalues 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
.
If a transformation has been applied (any one of
transform.power
is not one, scale
is not one and
offset
is nonzero), the backtransforms of the transformed
values and their lower and upper confidence intervals are added
to a data.frame
that is consistent with a
predictions.frame
. If transform.power
is other than
one, the standard.error
column of the data.frame
is set to NA
. This data.frame
is added to the
alldiffs.object
as a list
component called
backtransforms
.
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' linTransform(alldiffs.obj, classify = NULL, term = NULL, linear.transformation = NULL, Vmatrix = FALSE, error.intervals = "Confidence", avsed.tolerance = 0.25, meanLSD.type = "overall", LSDby = NULL, response = NULL, response.title = NULL, x.num = NULL, x.fac = NULL, tables = "all", level.length = NA, pairwise = TRUE, alpha = 0.05, inestimable.rm = TRUE, ...)
alldiffs.obj 
An 
classify 
A 
term 
A 
linear.transformation 
A If a In either case, as well as the values of the linear combinations, their standard errors, pairwise differences and associated statistics are returned. 
Vmatrix 
A 
error.intervals 
A 
avsed.tolerance 
A

meanLSD.type 
A 
LSDby 
A 
response 
A 
response.title 
A 
x.num 
A 
x.fac 
A 
tables 
A 
level.length 
The maximum number of characters from the the levels of factors to use in the row and column labels of the tables of pairwise differences and their pvalues and standard errors. 
pairwise 
A 
alpha 
A 
inestimable.rm 
A 
... 
further arguments passed to 
For a matrix L, vector of predictions p and variance matrix of the predictions V_p, the linear transformed predictions are given by Lp with variance matrix LVL^T. The last matrix is used to compute the variance of pairwise differences between the transformed values.
The matrix
L is directly specified by setting
linear.transformation
to it. If linear.transformation
is a
formula
then L is formed as the sum of the
orthogonal projection matrices obtained using pstructure.formula
from the package dae
; grandMean
is set to TRUE
and
orthogonalize
to "eigenmethods"
.
A alldiffs.object
with the linear transformation of the predictions
and their standard errors and all pairwise differences between the linear
transforms of their predictions, their standard errors and pvalues
and LSD statistics.
If the supplied alldiffs.object
contained a backtransforms
componnent, then the returned alldiffs.object
will contain
a backtransforms
component with the backtransformed linear transformation
of the predictions. The backtransformation will, after backtransforming for any
power transformation, subtract the offset
and then divide by the scale
.
If error.intervals
is not "none"
, then the
predictions
component and, if present, the
backtransforms
component will contain columns for the lower
and upper values of the limits for the interval. The names of these
columns will consist of three parts separated by full stops:
1) the first part will be lower
or upper
;
2) the second part will be one of Confidence
,
StandardError
or halfLeastSignificant
;
3) the third component will be limits
.
The name of the response
, the response.title
,
the term
, the classify
, tdf
, sortFactor
and the sortOrder
will be set as attributes to the object.
Chris Brien
predictPlus.asreml
, as.alldiffs
, print.alldiffs
,
sort.alldiffs
,
subset.alldiffs
,
allDifferences.data.frame
,
redoErrorIntervals.alldiffs
, recalcLSD.alldiffs
,
predictPresent.asreml
,
plotPredictions.data.frame
, as.Date
, predict.asreml
data(WaterRunoff.dat) ##Use asreml to get predictions and associated statistics ## Not run: asreml.options(keep.order = TRUE) #required for asremlR4 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) #Get additive predictions directly using predictPlus diffs.sub < predictPlus.asreml(classify = "Sources:Species", Vmatrix = TRUE, linear.transformation = ~ Sources + Species, 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 * Species) + (1Benches:MainPlots), data=na.omit(WaterRunoff.dat)) SS.emm < emmeans::emmeans(m1.lmer, specs = ~ Sources:Species) SS.preds < summary(SS.emm) den.df < min(SS.preds$df, na.rm = TRUE) ## Modify SS.preds to be compatible with a predictions.frame SS.preds < as.predictions.frame(SS.preds, predictions = "emmean", se = "SE", interval.type = "CI", interval.names = c("lower.CL", "upper.CL")) ## Form an all.diffs object and check its validity SS.vcov < vcov(SS.emm) SS.diffs < allDifferences(predictions = SS.preds, classify = "Sources:Species", vcov = SS.vcov, tdf = den.df) validAlldiffs(SS.diffs) #Get additive predictions diffs.sub < linTransform(SS.diffs, classify = "Sources:Species", linear.transformation = ~ Sources + Species, Vmatrix = TRUE, tables = "none") } ##Calculate contrasts from prediction obtained using asreml or lmerTest if (exists("diffs.sub")) { #Contrast matrix for differences between each species and nonplanted for the last source L < cbind(matrix(rep(0,7*32), nrow = 7, ncol = 32), diag(1, nrow = 7), matrix(rep(1, 7), ncol = 1)) rownames(L) < as.character(diffs.sub$predictions$Species[33:39]) diffs.L < linTransform(diffs.sub, classify = "Sources:Species", linear.transformation = L, tables = "predictions") }