met_smooth_loess: LOESS smoothing

Description Usage Arguments Value Examples

View source: R/correction.R

Description

Wraps LOESS smoothing function for use in bias correction algorithm. WARNING: LOESS is not a particularly good choice for bias correction. This function is included for completeness only.

Usage

1
met_smooth_loess(time, concentration, new.time = NULL, ...)

Arguments

time

Time or sample number for metabolite time-course.

concentration

Metabolite concentration.

new.time

Optional vector for new independent variables.

...

Arguments to be passed into the loess() smoothing function, such as span – "the parameter alpha which controls the degree of smoothing". If no additional arguments are provided, a reasonable default for span (0.75) is assumed.

Value

A vector of smoothed concentrations.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Simulating concave curve with 10 points
par <- c(3.5, 4.5, 2.5, 3.5, 0.0, 0.2, 0.8, 0.9)
concentration <- as.numeric(simulate_concave(1, 10, par))

# Adding noise and changing scale
concentration <- concentration * 18 + 2
abs.sd <- mean(concentration) * 0.1
concentration <- concentration + rnorm(10, 0, abs.sd)
concentration[concentration < 0] <- 0

# Original sample time
time <- seq(0, 9, length.out=10) * 24

# New time for smoothing
new.time <- seq(0, 9, length.out=100) * 24

# Smoothing
corrected <- met_smooth_loess(time, concentration,
                              new.time = new.time, span = 0.75)

# Plotting
plot(time, concentration, type='p',
     xlab='Time post inoculation (hours)', ylab='Concentration (mM)')
lines(new.time, corrected, type='l')

ssokolen/metcourse documentation built on May 30, 2019, 8:43 a.m.