ncp_est | R Documentation |
This function estimates the non-centrality parameter (NCP) of data assuming a non-central chi squared distribution with known degrees of freedom. The function first uses the method of moments (MOM) to get a rough estimate of the NCP, then uses that as a starting point for calculating the maximum likelihood estimate (MLE).
ncp_est(x, df)
x |
The vector of data whose parameter we are interested in. The data is assumed to follow a non-central chi squared distribution, and appropriate inputs are deviance or likelihood ratio test statistics, or other tests that ordinarily follow a central chi-squared distribution but become non-central due to "double dipping" (where fixed variables being tested were in fact estimated from the same data). Any values that are NA, infinites, or negatives are ignored (removed before all calculations). |
df |
The degrees of freedom of the test used to calculate the statistics. |
There is one case where this function does not calculate MLEs directly, due to numerical issues, namely when the MOM estimate is negative, in which case estimates of zero for both are returned. Negative MOM NCP estimates arise in two common cases. First, the data has a central chi squared distribution, in which case the NCP estimate may take on small negative values, and overall these estimates have a mean of zero and variance dependent on sample size; in this case the return values of zero are appropriate. Second, the data may not have a central or non-central chi squared distribution at all, in which case the estimation model is completely misspecified; we opted to return zero estimates quietly, without issuing errors or warnings, as this case overlaps with central chi-squared data and it's not trivial to tell the difference. This function does not aim to detect misspecified data, it is up to the researcher to compare the model against the observed statistics for goodness of fit, for example using q-q plots.
A numeric vector with two values, namely the MLE and MOM estimates.
pvals_nc_chisq()
, a wrapper around this function that facilitates p-value calculation for Jackstraw objects.
# true parameters of toy data
df <- 1
ncp_true <- 1
x <- rchisq( 100, df, ncp_true )
# get estimates!
ncp_ests <- ncp_est( x, df )
# this is MLE
ncp_ests[1]
# this is MOM estimate
ncp_ests[2]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.