pickLSDstatistics.alldiffs {asremlPlus}R Documentation

Pick LSDstatistics whose values minimize the number of errors in pairwise comparisons of predictions.

Description

Given an alldiffs.object with an sed component, exploreLSDs.alldiffs is used to calculate the LSD values for each set of prediction comparisons specified by LSDtype and LSDby using each of the statistics minimum, q10, q25, mean, median, q75, q90 and maximum. Then the numbers of false positives and false negatives resulting from employing each of the calculated LSDs is obtained. For each set of comparisons, the LSD value(s) with the lowest number of false positives are identified and, from these, the smallest value with the lowest number of false negatives. That is, a conservative approach is taken to picking LSD values by putting the priority on avoiding false positives. Before using the LSDstatistics that this function suggests, the number of false positives and negatives generated by them should be checked. For example, it may be that there are too many false negatives and a better balance between the numbers of false positives and negatives can be identified using exploreLSDs.alldiffs,

Usage

## S3 method for class 'alldiffs'
pickLSDstatistics(alldiffs.obj, 
                  LSDtype = "overall", LSDby = NULL, 
                  alpha = 0.05, digits = 3, 
                  false.pos.wt = NULL, retain.zeroLSDs = FALSE, 
                  zero.tolerance = .Machine$double.eps ^ 0.5, 
                  ...)

Arguments

alldiffs.obj

An alldiffs.object.

LSDtype

A character string that can be overall or factor.combinations. It determines whether the LSD values that are investigated and stored are (i) the overall minimum, quantile10, quantile25, mean, median, quantile75, quantile90, and maximum of all pairwise LSDs, or (ii) the minimum, quantile10, quantile25, mean, median, quantile75, quantile90, and maximum for the pairwise LSDs for each combination of the values of the factors and numerics named in LSDby, unless there is only one prediction for a combination, when notional LSDs are calculated. The LSDtype specified here does not have to match that used in the creating the alldiffs.object.

See LSD.frame for further information on how the LSD statistics are calculated.

LSDby

A character (vector) of variables names, being the names of the factors or numerics in the classify; for each combination of the values the of the factors and numerics, the LSD errors are to be computed when LSDtype is factor.combinatons. The LSDby specified here does not have to match that used in the creating the alldiffs.object.

alpha

A numeric specifying the significance level for an LSD to compare a pair of predictions.

digits

A numeric specifying the number of significant digits to retain in rounding the LSDs before determining the distinct rounded LSDs.

false.pos.wt

When it is not NULL, it should be a numeric that specifies the weight (e.g. 3) to apply to the number of false positives in calculating the weighted sums of the numbers of false positives and negatives in using different LSD statistics to compare pairs of predictions. The LSDstatistic that is chosen for making comparisons will be the one that minimizes the weighted sum. If it is NULL, the LSDstatistic will chosen as the one that minimizes the number of false negatives from amongst those that minimize the number of false positives.

retain.zeroLSDs

A logical indicating whether to retain or omit LSDs that are zero when calculating the summaries of LSDs.

zero.tolerance

A numeric specifying the value such that if an LSD is less than it, the LSD will be considered to be zero.

...

Provision for passing arguments to functions called internally - not used at present.

Value

A character of length one for LSDby set to overall or of length equal to the number of observed combinations of the values of the factors and numerics in LSDby. Each element of the returned character is one of minimum, q10, q25, mean, median, q75, q90 or maximum, reflecting the value(s) of the LSD from amongst those calculated that minimizes the number of false positives; if there is more than one such value, then the element will be correspond to the value of the LSD from amongst those with the minimum number of false positives that minimizes the number of false negatives.

Author(s)

Chris Brien

See Also

asremlPlus-package, exploreLSDs.alldiffs plotLSDs.data.frame, plotLSDs.alldiffs,
plotLSDerrors.alldiffs, plotLSDerrors.data.frame, recalcLSD.alldiffs,
redoErrorIntervals.alldiffs

Examples

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)
}  

## Plot p-values for predictions obtained using asreml or lmerTest
if (exists("TS.diffs"))
{
  ##Pick the LSD values for predictions obtained using asreml or lmerTest  
  LSDstat <- pickLSDstatistics(TS.diffs)
  TS.diffs <- redoErrorIntervals(TS.diffs, LSDstatistic = LSDstat)
  TS.diffs$LSD
  LSDstat <- pickLSDstatistics(TS.diffs, LSDtype = "factor.combinations", 
                         LSDby = "Sources")
  TS.diffs <- redoErrorIntervals(TS.diffs, LSDtype = "factor.combinations", 
                                 LSDby = "Sources", LSDstatistic = LSDstat)
  TS.diffs$LSD
}

[Package asremlPlus version 4.4.32 Index]