smooth1d {OCplus} | R Documentation

## Smoothing a vector of counts

### Description

This function takes a vector of counts and uses a mixed model approach to smooth it. A common use of this is smoothing binned counts of an observed quantity prior to estimating its density nonparametrically through the relative frequencies.

### Usage

    smooth1d(y, sv2 = 0.1, err = 0.01, verb = TRUE)

### Arguments

`y` | the vector of counts
`sv2` | the user-specified starting value for the variance of the random effects, see Details.
`err` | Tolerance for convergence, see Details
`verb` | logical value indicating whether to print diagnostics.

### Details

The smoothing assumes that the counts are Poisson from a generalized linear mixed model, where the second differences are normally distributed. Using the extended likelihood approach described in Pawitan (2001) and the initial estimate `sv2` for the variance of the random effects, the routine iteratetively optimizes the fixed and random contributions to the extended likelihood, until the estimate for the variance convergences with tolerance `err`. The result is quite stable within a reasonable range of starting values and tolerances, and the function can be used for fairly automatic smoothing ((i.e. withou fixing a bandwidth parameter).

### Value

A list with three components:

`fit` | the smoothed counts
`df` | the degrees of freedom used for smoothing at convergence
`sv2` | the estimated variance at convergence, equivalent to `df`.

### Author(s)

Y. Pawitan and A. Ploner

### References

Pawitan Y.(2001) In All Likelihood, Oxford University Press, ch. 18.11

### See Also

`fdr1d`

### Examples

    # Stupid dummies, obviously
    smooth1d(1:10)
    smooth1d(1:10, sv2=1)

[Package OCplus version 1.62.0 Index]