BTD: Bayesian Test of Deficit

BTDR Documentation

Bayesian Test of Deficit

Description

Takes a single observation and compares it to a distribution estimated by a control sample using Bayesian methodology. Calculates standardised difference between the case score and the mean of the controls and proportions falling above or below the case score, as well as associated credible intervals. This approach was developed by Crawford and Garthwaite (2007) but converge to the results of TD(), which is faster. Returns the point estimate of the standardised difference between the case score and the mean of the controls and the point estimate of the p-value (i.e. the percentage of the population that would be expected to obtain a lower or higher score, depending on the alternative hypothesis). This test is based on random number generation which means that results may vary between runs. This is by design and the reason for not using set.seed() to reproduce results inside the function is to emphasise the randomness of the test. To get more accurate and stable results please increase the number of iterations by increasing iter whenever feasible.

Usage

BTD(
  case,
  controls,
  sd = NULL,
  sample_size = NULL,
  alternative = c("less", "greater", "two.sided"),
  int_level = 0.95,
  iter = 10000,
  na.rm = FALSE
)

Arguments

case

Case observation, can only be a single value.

controls

Numeric vector of observations from the control sample. If single value, treated as mean.

sd

If input of controls is single value, the standard deviation of the sample must be given as well.

sample_size

If input of controls is single value, the size of the sample must be given as well.

alternative

A character string specifying the alternative hypothesis, must be one of "less" (default), "greater" or "two.sided". You can specify just the initial letter.

int_level

Level of confidence for credible intervals, defaults to 95%.

iter

Number of iterations. Set to higher for more accuracy, set to lower for faster calculations.

na.rm

Remove NAs from controls.

Value

A list with class "htest" containing the following components:

statistic the mean z-value over iter number of iterations
parameter the degrees of freedom used to specify the posterior distribution.
p.value the mean p-value for all simulated Z-scores.
estimate estimated standardised difference (Z-CC) and point estimate of p-value.
null.value the value of the difference under the null hypothesis.
interval named numerical vector containing credibility level and intervals for both Z-CC and estimated proportion.
desc named numerical containing descriptive statistics: mean and standard deviations of controls as well as sample size.
alternative a character string describing the alternative hypothesis.
method a character string indicating what type of test was performed.
data.name a character string giving the name(s) of the data as well as summaries.

References

Crawford, J. R., & Garthwaite, P. H. (2007). Comparison of a single case to a control or normative sample in neuropsychology: Development of a Bayesian approach. Cognitive Neuropsychology, 24(4), 343-372. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/02643290701290146")}

Examples

BTD(case = -2, controls = 0, sd = 1, sample_size = 20, iter = 1000)

BTD(case = size_weight_illusion[1, "V_SWI"],
    controls = size_weight_illusion[-1, "V_SWI"], alternative = "l", iter = 1000)


singcar documentation built on March 31, 2023, 9:25 p.m.