Description Usage Arguments Details Value Side Effects References See Also Examples

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

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

`x` |
a vector of data. |

`group` |
a vector of group labels. If this is not already a factor it will be converted to a factor. |

`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 |

`...` |
other optional parameters are passed to the |

For a general description of the methods involved, see Section 6.2 of the reference below.

The colours and linetypes of the density estimates are set by `col`

and `lty`

which can be passed as additional arguments. By default these are set to `1 + 1:ngroup`

, where `ngroup`

is the number of groups represented in the `group`

variable.

A list is returned containing:

`estimate` |
a matrix whose rows contain the estimates for each group. |

`eval.points` |
the grid of common evaluation points for the estimates. |

`h` |
the common smoothing parameter used in the construction of the estimates. |

`levels` |
the levels of the group factor. |

`col, lty, lwd` |
plotting details which can be useful in constructing a legend for the plot; see the examples below. |

When `"model"`

is set to `"equal"`

, the output list also contains the p-value (`p`

) of the test.

When `band = TRUE`

, and there are only two groups to compare, the output list also contains the upper (`upper`

) and lower (`lower`

) edges of the reference band for equality.

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

.

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

`sm.density`

, `sm.ancova`

, `sm.options`

1 2 3 4 5 6 | ```
y <- rnorm(100)
g <- rep(1:2, rep(50,2))
sm.density.compare(y, g)
comp <- sm.density.compare(y, g, model = "equal")
legend("topleft", comp$levels, col = comp$col, lty = comp$lty, lwd = comp$lwd)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.