View source: R/alldiffs.findLSD.v1.r
findLSDminerrors.alldiffs | R Documentation |
Given an alldiffs.object
with an sed
component,
a search is made of a set of equally spaced values between the minimum and
maximum values of the LSDs, calculated from the sed
component of the
alldiffs.object
, to identify LSD values that minimize the number
of errors made in deciding on the significance of pairs of predicted values stored
in the alldiffs.object
. If LSDtype
is set to overall
,
a search is made over the range of LSD values for all pairwise comparisons for a
single LSD value; if LSDtype
is set to factor.combinations
,
a separate search is made over the LSD values for the set of pairwise comparisons
for each factor.combination
in order to identify a single value for each set.
The number of values used in the search is controlled by the argument nvalues
.
For each value in the search, the numbers of false positives and false negatives
resulting from employing it as the LSD for each set of pairwise comparisons is calculated.
A criterion that combines the false positives and negative is calculated using the
false.pos.wt
, the criterion being the number of false postives times the
false.pos.wt
plus the number of false negatives. The value chosen for the LSD
is the smallest value from amongst those with the minimum value of the criterion and
the least number of false positives. A secondary search with 10 equally spaced values
is made of the interval below the chosen value and the search value immediately below
it to check whether the chosen grid value can be further reduced without changing the
value of either its criterion or the number of false positives.
The primary options for changing the numbers of errors associated with the values
resulting from the searching is to manipulate the LSDby
and/or
false.pos.wt
arguments.
## S3 method for class 'alldiffs'
findLSDminerrors(alldiffs.obj,
LSDtype = "overall", LSDby = NULL,
alpha = 0.05,
false.pos.wt = 10, nvalues = 100,
retain.zeroLSDs = FALSE,
zero.tolerance = .Machine$double.eps ^ 0.5,
trace = FALSE, ...)
alldiffs.obj |
An |
LSDtype |
A |
LSDby |
A |
alpha |
A |
false.pos.wt |
A The default of 10 for |
nvalues |
A |
retain.zeroLSDs |
A |
zero.tolerance |
A |
trace |
A |
... |
Provision for passing arguments to functions called internally - not used at present. |
A data.frame
containing the chosen LSD(s), its(their) numbers of false positives
and negatives and the value(s) of the false criterion.
Chris Brien
asremlPlus-package
, exploreLSDs.alldiffs
plotLSDs.data.frame
,
plotLSDs.alldiffs
,
plotLSDerrors.alldiffs
, plotLSDerrors.data.frame
, recalcLSD.alldiffs
,
redoErrorIntervals.alldiffs
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(classify = "Sources:Type",
asreml.obj = current.asr,
wald.tab = current.asrt$wald.tab,
present = c("Sources", "Type", "Species"))
## 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)
}
## Choose LSD values with the minimum mumber of error for pairwise comparisons of
## the predictions obtained using asreml or lmerTest
if (exists("TS.diffs"))
{
##Pick the LSD values for predictions obtained using asreml or lmerTest
minLSD <- findLSDminerrors(TS.diffs)
TS.diffs <- redoErrorIntervals(TS.diffs, LSDtype = "supplied", LSDsupplied = minLSD["LSD"])
TS.diffs$LSD
minLSDs <- findLSDminerrors(TS.diffs, LSDtype = "factor.combinations",
LSDby = "Sources")
TS.diffs <- redoErrorIntervals(TS.diffs, LSDtype = "supplied",
LSDby = "Sources", LSDsupplied = minLSDs["LSD"])
TS.diffs$LSD
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.