Class StudentsTStat.PairedDiff

Enclosing class:
StudentsTStat

public static class StudentsTStat.PairedDiff extends StudentsTStat
Student's t statistic for dependent paired differences. For a data set x1i and a data set x2i the difference di = x2i-x1i will be computed and added to the statistic. The distributions from which each pair of values is taken are assumed to have the same variances. The statistic is t = (XD - μ0) / (sD/sqrt(n)) where
  • XD is the mean value of a data set of differences D.
  • sD is the sample standard deviation for D.
  • n is the size of the data set.
  • μ0 is the value against which D's mean value will be tested.
  • Constructor Details

    • PairedDiff

      public PairedDiff(double mu0)
      Constructor. Data must be added by using the method add(double,double) or add(double).
      Parameters:
      mu0 - the specified mean value to test against
    • PairedDiff

      public PairedDiff(double mu0, double mean, double variance, long n)
      Constructor given a mean value to test against and a description of a data set.
      Parameters:
      mu0 - the mean value to test against
      mean - the mean value of the data set
      variance - the sample variance of the data set
      n - the size of the data set
    • PairedDiff

      public PairedDiff(double mu0, double[] x1, double[] x2)
      Constructor given paired values. For a data set x1i and a data set x2i the difference di = x2i-x1i will be computed and added to the statistic.
      Parameters:
      mu0 - the specified mean value to test against
      x1 - the first values from each of the pairs
      x2 - the second values from each of the pairs.
    • PairedDiff

      public PairedDiff(double mu0, double[] diff)
      Constructor given differences. For a data set x1i and a data set x2i the difference di = x1i-x2i. This constructor specifies the mean value against which the statistic tests the data and specifies an initial set of differences between paired valued.
      Parameters:
      mu0 - the specified mean value to test against
      diff - the difference in values between each pair
  • Method Details

    • getSpecifiedMean

      public double getSpecifiedMean()
      Get the specified value, against which the data set's mean value will be tested.
      Returns:
      the specified value for the mean
    • getMean

      public double getMean()
      Get the mean of the data set x2i - x1i.
      Returns:
      the mean value of data set
    • getSDev

      public double getSDev()
      Get the sample standard deviation of the data set x2i - x1i.
      Returns:
      the sample standard deviation for the data set
    • add

      public void add(double x1, double x2)
      Add paired values. The difference x2-x1 will be added.
      Parameters:
      x1 - the first paired value
      x2 - the second paired value
    • add

      public void add(double diff)
      Add a difference.
      Parameters:
      diff - the difference
    • getValue

      public double getValue()
      Description copied from class: Statistic
      Get the value of this statistic.
      Specified by:
      getValue in class Statistic
      Returns:
      the value of this statistic
    • getNCParameter

      public double getNCParameter(double diff)
      Description copied from class: StudentsTStat
      Get the noncentrality parameter given a difference in mean values. A Student's t-test can typically be written as $$ T = \frac{\mbox{x̅} - \mu_0}{ \frac{\sigma}{\sqrt{n}} \sqrt{\frac{S}{\sigma^2\nu}} }$$ where ν is the number of degrees of freedom, σ is the population standard deviation of a random variable for which x is the sample mean of X, μ0 is the population mean of X, n is the sample size, and S is a sum of squares. Note that $\sqrt{\frac{S}{\sigma^2\nu}}$ will be the sample standard deviation for a suitable choice of ν.

      If we set θ = μ1 - μ0, we can express T as $$T = \frac{\mbox{x̅} - \mu_0 +\theta - \theta }{ \frac{\sigma}{\sqrt{n}} \frac{S/\sigma^2}{\sqrt{\nu}} }$$ or $$T = \frac{\mbox{x̅} - \mu_1 + \theta }{ \frac{\sigma}{\sqrt{n}} \frac{S/\sigma^2}{\sqrt{\nu}} } \ .$$ If we set $Z = \frac{\mbox{x̅} - \mu_1}{\sigma/\sqrt{n}}$ and $\mu = \frac{\theta}{\sigma/\sqrt{n}}$, then T can be written as $\frac{Z+\mu}{\sqrt{V/\nu}}$. If the actual mean is μ1, then Z has a normal distribution with a mean of zero and a variance of 1. Meanwhile V has a χ2 distribution with ν degrees of freedom, and Z and V are independent. Consequently, the random variable $\frac{Z + \mu}{\sqrt{V/\nu}}$ has a noncentral t distribution characterized by the number of degrees of freedom ν and the noncentrality parameter μ.

      For citations for specific cases, please see

      The notation in this documentation will differ slightly due to the use of a lower-case x instead of an upper-case X as part of a work-around for a mathjax bug involving the LaTeX 'overline' command.
      Specified by:
      getNCParameter in class StudentsTStat
      Parameters:
      diff - the difference of the H1 mean value and the H0 mean value.
      Returns:
      the noncentrality parameter