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 |
A fast trimmed mean smoother (using C code) of data at discrete points (e.g. probe-level data).
tmeanC(sp, x, spout = NULL, nProbes = 10, probeWindow = 600, trim = 0.1)
tmeanC(sp, x, spout = NULL, nProbes = 10, probeWindow = 600, trim = 0.1)
sp |
numeric vector of positions (x-values) |
x |
numeric vector of data (corresponding to |
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 |
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.
vector (of the same length as sp
(or spout
)) giving the trimmed mean smoothed values
Mark Robinson
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")
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")
A slow trimmed mean smoother (using R code) of data at discrete points (e.g. probe-level data).
trimmedMean(pos, score, probeWindow=600, meanTrim=.1, nProbes=10)
trimmedMean(pos, score, probeWindow=600, meanTrim=.1, nProbes=10)
pos |
numeric vector of positions (x-values) |
score |
numeric vector of data (corresponding to |
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 |
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.
vector (of the same length as sp
giving the trimmed mean smoothed values
Mark Robinson
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)
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)