interpolate_counts: Interpolate counts to specific time periods

Description Usage Arguments Details Value Examples

Description

This function uses data (sample ages and sample counts) from an epd.entity.df-class object to estimate by linear interpolation, loess or smooth splines the counts at specific time periods defined by the user. This can be used to estimate counts for the same time periods for multiple entities in the database, standardizing them for integrative analysis.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
interpolate_counts(x, time, chronology = NULL, method = c("linear", "loess",
  "sspline"), rep_negt = TRUE, span = 0.25, df = min(20,
  nrow(x@commdf@counts) * 0.7), ...)

## S4 method for signature 'epd.entity.df,numeric'
interpolate_counts(x, time,
  chronology = NULL, method = c("linear", "loess", "sspline"),
  rep_negt = TRUE, span = 0.25, df = min(20, nrow(x@commdf@counts) * 0.7),
  ...)

## S4 method for signature 'epd.entity,numeric'
interpolate_counts(x, time, chronology = NULL,
  method = c("linear", "loess", "sspline"), rep_negt = TRUE, span = 0.25,
  df = min(20, nrow(x@commdf@counts) * 0.7), ...)

Arguments

x

epd.entity.df An epd.entity.df-class or epd.entity-class object as returned by get_entity or entity_to_matrices functions.

time

numeric Vector with time periods, in the same system (i.e., cal BP) than "ages" in epd.entity.df, in which counts have to be estimated.

chronology

numeric Number specifying the chronology from which ages should be used to calculate the interpolations. If none is provided the function uses the default chronology from the object (see giesecke_default_chron or check_defaultchron).

method

character Interpolation method, should be an unambiguous abbreviation of either linear, loess, or sspline. See Details section.

rep_negt

logical logical to indicate whether or not to replace negative values with zero in the interpolated data.

span

numeric Span for loess, default = 0.25.

df

numeric Degress of freedome for smoothing spline, default is the lower of 20 or 0.7 * number of samples.

...

additional arguments to loess and smooth.spline.

Details

Data for time periods in time but not recorded in the entity are fill with NA. This is convenient if analysis are carried out with multiple entities.

Interpolation can be done using linear interpolation between data points in the original series (default) using approxfun, using a fitted loess locally weighted regression, or by smooth.spline. The latter two methods will also smooth the data and additional arguments may be passed to these functions to control the amount of smoothing, or to force replacing negative values with zeros.

Value

The function returns an epd.entity.df-class object, similar to x in which ages and counts has been modified to the time periods specified in time and the counts estimated for these periods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
epd.connection <- connect_to_epd(host="localhost", database="epd",
                                 user="epdr", password="epdrpw")
t <- c(seq(0, 21000, by = 500))
epd.1 <- get_entity(1, epd.connection)
epd.1.int <- interpolate_counts(epd.1, t)

epd.3 <- get_entity(3, epd.connection)
epd.3.int <- interpolate_counts(epd.3, t, method="linear")
epd.3.int <- interpolate_counts(epd.3, t, method="loess")
epd.3.int <- interpolate_counts(epd.3, t, method="sspline")

## End(Not run)

dinilu/EPDr documentation built on Jan. 13, 2018, 9:03 p.m.