- Enclosing class:
- StudentsTStat
- 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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bzdev.math.stats.StudentsTStat
StudentsTStat.Mean1, StudentsTStat.Mean2, StudentsTStat.PairedDiff, StudentsTStat.Slope
Nested classes/interfaces inherited from class org.bzdev.math.stats.Statistic
Statistic.PValueMode
-
Constructor Summary
ConstructorsConstructorDescriptionPairedDiff
(double mu0) Constructor.PairedDiff
(double mu0, double[] diff) Constructor given differences.PairedDiff
(double mu0, double[] x1, double[] x2) Constructor given paired values.PairedDiff
(double mu0, double mean, double variance, long n) Constructor given a mean value to test against and a description of a data set. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(double diff) Add a difference.void
add
(double x1, double x2) Add paired values.double
getMean()
Get the mean of the data set x2i - x1i.double
getNCParameter
(double diff) Get the noncentrality parameter given a difference in mean values.double
getSDev()
Get the sample standard deviation of the data set x2i - x1i.double
Get the specified value, against which the data set's mean value will be tested.double
getValue()
Get the value of this statistic.Methods inherited from class org.bzdev.math.stats.StudentsTStat
getDegreesOfFreedom, getDistribution, getDistribution, setDegreesOfFreedom
Methods inherited from class org.bzdev.math.stats.Statistic
getBeta, getBeta, getCriticalValue, getNCParameter, getPower, getPower, getPValue, optimalValue
-
Constructor Details
-
PairedDiff
public PairedDiff(double mu0) Constructor. Data must be added by using the methodadd(double,double)
oradd(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 againstmean
- the mean value of the data setvariance
- the sample variance of the data setn
- 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 againstx1
- the first values from each of the pairsx2
- 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 againstdiff
- 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 valuex2
- 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. -
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
- Sample Size & Power Calculations and Sample size and power calculations using the noncentral t-distribution for two-sample case.
- Statistical power of the t-tests for the one-sample case.
- Specified by:
getNCParameter
in classStudentsTStat
- Parameters:
diff
- the difference of the H1 mean value and the H0 mean value.- Returns:
- the noncentrality parameter
-