dpeak | R Documentation |
This function computes P(n,k)
as defined by
\insertCiteGoldfeld65;textualskedastic, i.e. the probability that a
sequence of n
independent and identically distributed random variables
contains exactly k
peaks, with peaks also as defined by
\insertCiteGoldfeld65;textualskedastic. The function is used in
ppeak
to compute p
-values for the Goldfeld-Quandt
nonparametric test for heteroskedasticity in a linear model.
dpeak(k, n, usedata = FALSE)
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 |
A double between 0 and 1 representing the probability of exactly
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.
Computation time is very slow for
n > 170
(if usedata
is FALSE
) and for n > 1000
regardless of usedata
value.
ppeak
, goldfeld_quandt
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.