- Direct Known Subclasses:
LeveneStat
An F-test statistic is based on the F distribution. An F distribution is the distribution of the random variable (X1/ν1) / (X2/ν2), where X1 and X2 are independent random variables with a χ2 distribution with ν1 and ν2 degrees of freedom respectively.
For noncentral F-distributions, the random variable X1 defined above has a noncentral χ2 distribution with a noncentrality parameter λ. This class provides methods to compute the noncentrality parameter.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bzdev.math.stats.Statistic
Statistic.PValueMode
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlong
Get the degrees of freedom for the numerator.long
Get the degrees of freedom for the denominator.Get the probability distribution for this statistic.getDistribution
(double lambda) Get a noncentral distribution for this statistic.double
getNCParameter
(double diff) Get the noncentrality parameter appropriate for this statistic.double
getNCParameter
(double... diffs) Get the noncentrality parameter appropriate for this statistic given multiple differences.protected void
setDegreesOfFreedom
(long nu1, long nu2) Set the degrees of freedom.protected void
setSize
(long sz1) Set the data-set size.Methods inherited from class org.bzdev.math.stats.Statistic
getBeta, getBeta, getCriticalValue, getPower, getPower, getPValue, getValue, optimalValue
-
Constructor Details
-
FStat
protected FStat()Constructor. -
FStat
protected FStat(long nu1, long nu2, long sz1) Constructor specifying degrees of freedom and the dataset size- Parameters:
nu1
- the number of degrees of freedom for the numeratornu2
- the number of degrees of freedom for the denominator.sz1
- the data-set size.
-
-
Method Details
-
getDegreesOfFreedom1
public long getDegreesOfFreedom1()Get the degrees of freedom for the numerator.- Returns:
- the degrees of freedom
-
getDegreesOfFreedom2
public long getDegreesOfFreedom2()Get the degrees of freedom for the denominator.- Returns:
- the degrees of freedom
-
setDegreesOfFreedom
protected void setDegreesOfFreedom(long nu1, long nu2) Set the degrees of freedom.- Parameters:
nu1
- the number of degrees of freedom for the numeratornu2
- the number of degrees of freedom for the denominator.
-
setSize
protected void setSize(long sz1) Set the data-set size.- Parameters:
sz1
- the data-set size.
-
getDistribution
Description copied from class:Statistic
Get the probability distribution for this statistic. The distribution is the distribution for the statistic, not the the distribution for the data the statistic describes.- Specified by:
getDistribution
in classStatistic
- Returns:
- the probability distribution
- Throws:
IllegalStateException
- the value cannot be computed (for example, because data has not yet been entered)
-
getDistribution
public ProbDistribution getDistribution(double lambda) throws IllegalArgumentException, IllegalStateException Get a noncentral distribution for this statistic. The definition of λ provided byFDistr
is such that, if the mean of k independent, normally distributed random variables is μi and these random variables have variances equal to 1.0, then the distribution of the sum of the squares of these random variables is a noncentral χ2 distribution with k degrees of freedom and a noncentrality parameter &lamba;. For the statistic provided by this class, each of these random variables is a ratio of a difference and a quantity that is essential a standard deviation. The difference is the difference between a value Xi and an expected value Ei, and the standard deviation is the standard deviation for Xi. The χ2 distribution assumes that these ratios have a normal distribution with unit variances and a mean of 0. For a noncentral χ2 distribution, the ratios are assumed to have a non-zero mean. The noncentrality parameter λ is defined by $\lambda = \sum_{i=1}^k \mu_i$, where μi is the mean value of the ith ratio.If there are k degrees of freedom, but additional terms in the χ2 sum, it is possible to define k variables zi so that χ2 = z12 + ... + zk2, where the mean of each zi is zero and its standard deviation is 1. The same value for &lamba; will be obtained. All the xi variables must satisfy (n-k) linear equations that act as constraints, where n is the total number of terms.
- Overrides:
getDistribution
in classStatistic
- Parameters:
lambda
- the noncentrality parameter- Returns:
- the (noncentral) probability distribution
- Throws:
IllegalArgumentException
- the argument is not allowed for this statisticIllegalStateException
- the state of this statistic does not allow this function to return a meaningful value (e.g., because enough data has not be provided)
-
getNCParameter
public double getNCParameter(double diff) Get the noncentrality parameter appropriate for this statistic. The argument is equal to the difference E'i - Ei where E'i is the actual value and Ei is the value used when the constructor was called. This offset is assumed be the same for all i. If we set Yi = δi = E'i - Ei, then (Xi-Ei - δi + δi) / σi = (Xi - E'i + δi) / σi. The standard deviation of Xi is σi and hence the standard deviation of Yi is also σi. Consequently, the variance of (Yi + δi)/σi is 1.0 and the corresponding mean value μi = δi / σi. The distribution of $\sum_{i=1}^k \frac{Y_i +\delta_i}{\sigma_i}$ is thus a noncentral χ2 with a non-centrality parameter $\lambda = \sum_{i=1}^k \mu_i$.This method computes λ for the case were the differences δi are identical. If the number of variables is larger than the number of degrees of freedom, the user must ensure that constraining all the δi values so that they are equal does not violate the constraint equations that reduce the number of degrees of freedom.
- Overrides:
getNCParameter
in classStatistic
- Parameters:
diff
- the difference from their expected values for the mean value of the random variables used in the sum of squares- Returns:
- the noncentrality parameter
- Throws:
IllegalStateException
- additional data was added after the constructor was called or the number of constraints was not zero
-
getNCParameter
public double getNCParameter(double... diffs) Get the noncentrality parameter appropriate for this statistic given multiple differences. The ith argument is equal to the difference E'i - Ei where E'i is the desired value and Ei is the value used when the constructor was called.If the number of variables is large than the number of degrees of freedom, the user must ensure that the choice of arguments is consistent with the constraint equations that reduce the number of degrees of freedom.
If there is only a single argument or an array of length 1, the argument or array value will be passed to
getNCParameter(double)
.- Overrides:
getNCParameter
in classStatistic
- Parameters:
diffs
- the difference from their expected values for the mean values of the random variables used in the sum of squares- Returns:
- the noncentrality parameter.
- Throws:
IllegalStateException
- additional data was added after the constructor was called or the number of constraints was not zero
-