Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sm.density.compare

Comparison of univariate density estimates


Description

This function allows a set of univariate density estimates to be compared, both graphically and formally in a permutation test of equality.

Usage

sm.density.compare(x, group, h, model = "none",  ...)

Arguments

x

a vector of data.

group

a vector of group labels.

h

the smoothing parameter to be used in the construction of each density estimate. Notice that the same smoothing parameter is used for each group. If this value is omitted, the mean of the normal optimal values for the different groups is used.

model

the default value is "none" which restricts comparison to plotting only. The alternative value "equal" can produce a bootstrap hypothesis test of equality and the display of an appropriate reference band.

...

other optional parameters are passed to the sm.options function, through a mechanism which limits their effect only to this call of the function. Those specifically relevant for this function are the following: method, df, band, test, nboot, plus those controlling graphical display (unless display="none" is set); see the documentation of sm.options for their description. The parameter nboot controls teh number of permutations used in the permutation test.

Details

see Section 6.2 of the reference below.

Value

When model is set to "none", nothing is returned. When "model" is set to "equal", a list containing the smoothing parameter and the p-value of the test is returned. When band takes the value TRUE, and there are only two groups to compare, the list contains in addition the upper and lower end-points of the reference band for equality.

Side Effects

a plot on the current graphical device is produced, unless display="none".

References

Bowman, A.W. and Azzalini, A. (1997). Applied Smoothing Techniques for Data Analysis: the Kernel Approach with S-Plus Illustrations. Oxford University Press, Oxford.

See Also

Examples

y <- rnorm(100)
g <- rep(1:2, rep(50,2))
sm.density.compare(y, g, model="equal")

sm

Smoothing Methods for Nonparametric Regression and Density Estimation

v2.2-5.6
GPL (>= 2)
Authors
Adrian Bowman and Adelchi Azzalini. Ported to R by B. D. Ripley <ripley@stats.ox.ac.uk> up to version 2.0, version 2.1 by Adrian Bowman and Adelchi Azzalini, version 2.2 by Adrian Bowman.
Initial release
2018-09-27

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.