Class StudentsTStat.Slope

Enclosing class:
StudentsTStat

public static class StudentsTStat.Slope extends StudentsTStat
Class providing Student's t-test to determine if the slope of a linear regression has a specific value. Using a value of 0 for the specified slope tests whether the x and y values are independent of each other.
  • Constructor Details

    • Slope

      public Slope(double beta0, double[] x, double[] y)
      Constructor. The x and y values must be arrays of equal lengths and each data point consists of an x and y value with the same index.
      Parameters:
      beta0 - the specified slope
      x - the X values
      y - the Y values
    • Slope

      public Slope(double beta0, double beta, double variance, double ssq, int n)
      Constructor given a description of the statistic.
      Parameters:
      beta0 - the specified slope
      beta - the slope determined by a least squares fit
      variance - the population variance of the x values used in the least-squares fit.
      ssq - the sum of the squares of the residuals
      n - the number of points used to create the least squares fit
  • Method Details

    • getFit

      public LeastSquaresFit.Polynomial getFit()
      Get the least squares fit (a polynomial fit of degree 1)
      Returns:
      the least squares fit for this statistic's data set; null if not available
    • 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