R: Trimmed Mean Smoother

tmeanC {gsmoothr} | R Documentation

## Trimmed Mean Smoother

### Description

A fast trimmed mean smoother (using C code) of data at discrete points (e.g. probe-level data).

### Usage

    tmeanC(sp, x, spout = NULL, nProbes = 10, probeWindow = 600, trim = 0.1)

### Arguments

`sp` | numeric vector of positions (x-values)
`x` | numeric vector of data (corresponding to `sp`
`spout` | optional vector of output values to calculate trimmed mean at, default: NULL
`nProbes` | minimum number of observations required within window
`probeWindow` | distance (in x) in each direction to look for observations to be used in the trimmed mean
`trim` | proportion of trim to use in trimmed mean

### Details

Using the specified probe window, this procedure uses all values within the window and calculates a trimmed mean with the specified amount of trim. If there are not enough observations within the window at a given position (as given by `nProbes`), a zero is returned.

### Value

vector (of the same length as `sp` (or `spout`)) giving the trimmed mean smoothed values

### Author(s)

Mark Robinson

### See Also

`trimmedMean`

### Examples

    sp <- seq(100, 1000, by=100)
    ss <- seq(100,1000, by=50)
    set.seed(14)
    x <- rnorm(length(sp))

    tmC <- tmeanC(sp, x, probeWindow=300, nProbes=5)
    tmC1 <- tmeanC(sp, x, spout=sp, probeWindow=300, nProbes=5)
    tmC2 <- tmeanC(sp, x, spout=ss, probeWindow=300, nProbes=5)

    cbind(tmC,tmC1)

    plot(sp, x, type="h", ylim=c(-2,2))
    lines(sp, tmC1, col="blue")
    lines(ss, tmC2, col="red")

[Package gsmoothr version 0.1.7 Index]