Create patterns

Share:

Description

Create temporal patterns from objects of class twdtwTimeSeries.

Usage

1
2
3
4
5
createPatterns(x, ...)

## S4 method for signature 'twdtwTimeSeries'
createPatterns(x, from = NULL, to = NULL,
  freq = 1, attr = NULL, split = TRUE, formula, ...)

Arguments

x

an object of class twdtwTimeSeries.

...

other arguments to pass to the function gam in the packege mgcv.

from

A character or Dates object in the format "yyyy-mm-dd". If not informed it is equal to the smallest date of the first element in x. See details.

to

A character or Dates object in the format "yyyy-mm-dd". If not informed it is equal to the greatest date of the first element in x. See details.

freq

An integer. The sampling frequency of the output patterns.

attr

A vector character or numeric. The attributes in x to be used. If not declared the function uses all attributes.

split

A logical. If TRUE the samples are split by label. If FALSE all samples are set to the same label.

formula

A formula. Argument to pass to gam.

Details

The hidden assumption is that the temporal pattern is a cycle the repeats itself within a given time interval. Therefore, all time series samples in x are aligned to each other keeping their respective sequence of days of the year. The function fits a Generalized Additive Model (GAM) to the aligned set of samples.

Value

an object of class twdtwTimeSeries

Author(s)

Victor Maus, vwmaus1@gmail.com

See Also

twdtwMatches-class, twdtwTimeSeries-class, getTimeSeries, and twdtwApply

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Creating patterns from objects of class twdtwTimeSeries 
evi = brick(system.file("lucc_MT/data/evi.tif", package="dtwSat"))
ndvi = brick(system.file("lucc_MT/data/ndvi.tif", package="dtwSat"))
timeline = scan(system.file("lucc_MT/data/timeline", package="dtwSat"), what="date")
rts = twdtwRaster(evi, ndvi, timeline=timeline)

# Read field samples 
## Not run: 
field_samples = read.csv(system.file("lucc_MT/data/samples.csv", package="dtwSat"))
prj_string = scan(system.file("lucc_MT/data/samples_projection", package="dtwSat"), 
                  what = "character")

# Extract time series 
ts = getTimeSeries(rts, y = field_samples, proj4string = prj_string)

# Create temporal patterns 
patt = createPatterns(x=ts, from="2005-09-01", to="2006-09-01", freq=8, formula = y~s(x))

# Plot patterns 
autoplot(patt[[1]], facets = NULL) + xlab("Time") + ylab("Value")


## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.