ppeak {skedastic}R Documentation

Cumulative distribution function of number of peaks in an i.i.d. random sequence

Description

This function computes \sum_{k} P(n,k), i.e. the probability that a sequence of n independent and identically distributed random variables contains \ge k (\le k) peaks, with peaks as defined in Goldfeld and Quandt (1965). The function may be used to compute p-values for the Goldfeld-Quandt nonparametric test for heteroskedasticity in a linear model. Computation time is very slow for n > 170 if usedata is set to FALSE.

Usage

ppeak(k, n, lower.tail = FALSE, usedata = TRUE)

Arguments

k

An integer or a sequence of integers strictly incrementing by 1, with all values between 0 and n - 1 inclusive. Represents the number of peaks in the sequence.

n

A positive integer representing the number of observations in the sequence.

lower.tail

A logical. Should lower tailed cumulative probability be calculated? Defaults to FALSE due to function being designed primarily for calculating p-values for the peaks test, which is by default an upper-tailed test. Note that both upper and lower tailed cumulative probabilities are computed inclusive of k.

usedata

A logical. Should probability mass function values be read from dpeakdat rather than computing them from dpeak? This option will save significantly on computation time if n < 170 but is currently only available for n \le 1000.

Value

A double between 0 and 1 representing the probability of at least (at most) k peaks occurring in a sequence of n independent and identically distributed continuous random variables. The double has a names attribute with the values corresponding to the probabilities.

References

Goldfeld SM, Quandt RE (1965). “Some Tests for Homoscedasticity.” Journal of the American Statistical Association, 60(310), 539–547.

See Also

dpeak, goldfeld_quandt

Examples

# For an independent sample of size 250, the probability of at least 10
# peaks is 0.02650008
ppeak(k = 10, n = 250, lower.tail = FALSE, usedata = TRUE)
# For an independent sample of size 10, the probability of at most 2 peaks
# is 0.7060615
ppeak(k = 2, n = 10, lower.tail = TRUE, usedata = FALSE)


[Package skedastic version 2.0.2 Index]