Package 'gsmoothr'

Title: Smoothing tools
Description: Tools rewritten in C for various smoothing tasks
Authors: Mark Robinson <[email protected]>
Maintainer: Mark Robinson <[email protected]>
License: LGPL (>= 2.0)
Version: 0.1.7
Built: 2024-10-31 22:07:58 UTC
Source: https://github.com/cran/gsmoothr

Help Index


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")

Trimmed Mean Smoother

Description

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

Usage

trimmedMean(pos, score, probeWindow=600, meanTrim=.1, nProbes=10)

Arguments

pos

numeric vector of positions (x-values)

score

numeric vector of data (corresponding to sp

probeWindow

distance (in x) in each direction to look for observations to be used in the trimmed mean

meanTrim

proportion of trim to use in trimmed mean

nProbes

minimum number of observations required within window

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 giving the trimmed mean smoothed values

Author(s)

Mark Robinson

See Also

tmeanC

Examples

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

tmC <- trimmedMean(sp, x, probeWindow=300, nProbes=5)