countpeaks {skedastic}R Documentation

Count peaks in a data sequence

Description

This function computes the number of peaks in a double vector, with peak defined as per Goldfeld and Quandt (1965). The function is used in the Goldfeld-Quandt nonparametric test for heteroskedasticity in a linear model. NA and NaN values in the sequence are ignored.

Usage

countpeaks(x)

Arguments

x

A double vector.

Value

An integer value between 0 and length(x) - 1 representing the number of peaks in the sequence.

References

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

See Also

goldfeld_quandt

Examples

set.seed(9586)
countpeaks(stats::rnorm(20))
mtcars_lm <- lm(mpg ~ wt + qsec + am, data = mtcars)
countpeaks(mtcars_lm$residuals)


[Package skedastic version 2.0.2 Index]