dpeak {skedastic} | R Documentation |
Probability mass function of number of peaks in an i.i.d. random sequence
Description
This function computes as defined by
Goldfeld and Quandt (1965), i.e. the probability that a
sequence of
independent and identically distributed random variables
contains exactly
peaks, with peaks also as defined by
Goldfeld and Quandt (1965). The function is used in
ppeak
to compute -values for the Goldfeld-Quandt
nonparametric test for heteroskedasticity in a linear model.
Usage
dpeak(k, n, usedata = FALSE)
Arguments
k |
An integer or a sequence of integers strictly incrementing by 1,
with all values between 0 and |
n |
A positive integer representing the number of observations in the sequence. |
usedata |
A logical. Should probability mass function values be
read from |
Value
A double between 0 and 1 representing the probability of exactly
k peaks occurring in a sequence of independent and identically
distributed continuous random variables. The double has a
names
attribute with the values corresponding to the probabilities.
Computation time is very slow for
(if
usedata
is FALSE
) and for
regardless of
usedata
value.
References
Goldfeld SM, Quandt RE (1965). “Some Tests for Homoscedasticity.” Journal of the American Statistical Association, 60(310), 539–547.
See Also
Examples
dpeak(0:9, 10)
plot(0:9, dpeak(0:9, 10), type = "p", pch = 20, xlab = "Number of Peaks",
ylab = "Probability")
# This would be extremely slow if usedata were set to FALSE:
prob <- dpeak(0:199, 200, usedata = TRUE)
plot(0:199, prob, type = "l", xlab = "Number of Peaks", ylab = "Probability")
# `dpeakdat` is a dataset containing probabilities generated from `dpeak`
utils::data(dpeakdat)
expval <- unlist(lapply(dpeakdat,
function(p) sum(p * 0:(length(p) - 1))))
plot(1:1000, expval[1:1000], type = "l", xlab = parse(text = "n"),
ylab = "Expected Number of Peaks")