This function computes a variety of summary statistics for each time series and numeric column within a time series list. The statistics include common metrics such as minimum, maximum, quartiles, mean, standard deviation, range, interquartile range, skewness, kurtosis, and autocorrelation for specified lags.
For irregular time series, autocorrelation computation is performed after regularizing the time series via interpolation with zoo_resample()
. This regularization does not affect the computation of all other stats.
This function supports progress bars generated by the progressr
package. See examples.
This function also accepts a parallelization setup via future::plan()
, but it might only be worth it for large time series lists.
Value
data frame:
name: name of the zoo object.
rows: rows of the zoo object.
columns: columns of the zoo object.
time_units: time units of the zoo time series (see
zoo_time()
).time_begin: beginning time of the time series.
time_end: end time of the time series.
time_length: total length of the time series, expressed in time units.
time_resolution: average distance between consecutive observations
variable: name of the variable, a column of the zoo object.
min: minimum value of the zoo column.
q1: first quartile (25th percentile).
median: 50th percentile.
q3: third quartile (75th percentile).
max: maximum value.
mean: average value.
sd: standard deviation.
range: range of the variable, computed as max - min.
iq_range: interquartile range of the variable, computed as q3 - q1.
skewness: asymmetry of the variable distribution.
kurtosis:"tailedness" of the variable distribution.
ac_lag_1, ac_lag_2, ...: autocorrelation values for the specified lags.
See also
Other tsl_processing:
tsl_aggregate()
,
tsl_resample()
,
tsl_transform()
Examples
#parallelization setup (not worth it for this data size)
future::plan(
future::multisession,
workers = 2 #set to parallelly::availableWorkers() - 1
)
#progress bar
# progressr::handlers(global = TRUE)
#three time series
#climate and ndvi in Fagus sylvatica stands in Spain, Germany, and Sweden
tsl <- tsl_initialize(
x = fagus_dynamics,
name_column = "name",
time_column = "time"
)
#stats computation
df <- tsl_stats(
tsl = tsl,
lags = 3
)
df
#> name rows colums time_units time_begin time_end time_length
#> 1 Germany 216 3 days 2001-01-01 2018-12-01 6543
#> 4 Spain 216 3 days 2001-01-01 2018-12-01 6543
#> 7 Sweden 216 3 days 2001-01-01 2018-12-01 6543
#> 2 Germany 216 3 days 2001-01-01 2018-12-01 6543
#> 5 Spain 216 3 days 2001-01-01 2018-12-01 6543
#> 8 Sweden 216 3 days 2001-01-01 2018-12-01 6543
#> 3 Germany 216 3 days 2001-01-01 2018-12-01 6543
#> 6 Spain 216 3 days 2001-01-01 2018-12-01 6543
#> 9 Sweden 216 3 days 2001-01-01 2018-12-01 6543
#> time_resolution variable min q1 median q3 max
#> 1 30.43256 evi 0.0689 0.328025 0.44070 0.581550 0.7528
#> 4 30.43256 evi 0.1828 0.271000 0.34525 0.466925 0.6434
#> 7 30.43256 evi 0.0413 0.203850 0.30580 0.608775 0.8764
#> 2 30.43256 rainfall 3.6000 37.450000 55.95000 76.850000 144.1000
#> 5 30.43256 rainfall 11.3000 55.650000 78.50000 117.550000 216.6000
#> 8 30.43256 rainfall 8.3000 40.775000 59.25000 82.075000 189.6000
#> 3 30.43256 temperature -1.9000 4.900000 10.40000 16.900000 23.2000
#> 6 30.43256 temperature 4.5000 8.700000 12.60000 17.700000 21.7000
#> 9 30.43256 temperature -4.7000 3.200000 8.15000 14.300000 20.0000
#> mean sd range iq_range skewness kurtosis ac_lag_1
#> 1 0.4475370 0.1467074 0.6839 0.253525 -0.05783267 -1.0177517 0.7223353
#> 4 0.3687245 0.1170178 0.4606 0.195925 0.28642807 -1.1547325 0.7709169
#> 7 0.3890579 0.2116391 0.8351 0.404925 0.27701665 -1.5166381 0.7577843
#> 2 58.7157407 27.8993379 140.5000 39.400000 0.51192914 -0.1499229 0.1321953
#> 5 91.1606481 48.1853638 205.3000 61.900000 0.75359061 -0.2612889 0.3567376
#> 8 64.7592593 32.5032507 181.3000 41.300000 0.87978813 0.7386146 0.2765852
#> 3 10.6861111 6.7015369 25.1000 12.000000 -0.05073437 -1.3166755 0.8147649
#> 6 13.0263889 4.7681695 17.2000 9.000000 0.04692060 -1.3981559 0.8208431
#> 9 8.5263889 6.5337833 24.7000 11.100000 -0.04126297 -1.3096657 0.8282803
#> ac_lag_2 ac_lag_3
#> 1 0.40102839 0.014216053
#> 4 0.43377523 0.009326848
#> 7 0.40574397 -0.008121973
#> 2 -0.06056026 -0.043789909
#> 5 0.13744019 -0.055413521
#> 8 0.08031474 -0.060240093
#> 3 0.46143388 0.004390029
#> 6 0.45715549 -0.004872615
#> 9 0.46942292 0.006882327
#disable parallelization
future::plan(
future::sequential
)