Skip to contents

dates is a matrix or list of (year, month, day) triples. Produces the book's time-based features plus the cyclic sine/cosine encoding of month and day of week, so December sits next to January. The calendar arithmetic is proleptic Gregorian and written out here, so both language arms agree without depending on a date library.

Usage

morie_calfeat(dates)

Arguments

dates

matrix or list of c(year, month, day)

Value

list(rows, n, nweekend, meandoy, meanmonthsin)

Examples

M <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2)
morie_calfeat(M)
#> $rows
#> $rows[[1]]
#> $rows[[1]]$year
#> [1] 1
#> 
#> $rows[[1]]$month
#> [1] 3
#> 
#> $rows[[1]]$day
#> [1] 5
#> 
#> $rows[[1]]$dow
#> [1] 0
#> 
#> $rows[[1]]$doy
#> [1] 64
#> 
#> $rows[[1]]$quarter
#> [1] 1
#> 
#> $rows[[1]]$week
#> [1] 10
#> 
#> $rows[[1]]$weekend
#> [1] 0
#> 
#> $rows[[1]]$monthstart
#> [1] 0
#> 
#> $rows[[1]]$monthend
#> [1] 0
#> 
#> $rows[[1]]$monthsin
#> [1] 1
#> 
#> $rows[[1]]$monthcos
#> [1] 6.123234e-17
#> 
#> $rows[[1]]$dowsin
#> [1] 0
#> 
#> $rows[[1]]$dowcos
#> [1] 1
#> 
#> 
#> $rows[[2]]
#> $rows[[2]]$year
#> [1] 2
#> 
#> $rows[[2]]$month
#> [1] 4
#> 
#> $rows[[2]]$day
#> [1] 6
#> 
#> $rows[[2]]$dow
#> [1] 5
#> 
#> $rows[[2]]$doy
#> [1] 96
#> 
#> $rows[[2]]$quarter
#> [1] 2
#> 
#> $rows[[2]]$week
#> [1] 14
#> 
#> $rows[[2]]$weekend
#> [1] 1
#> 
#> $rows[[2]]$monthstart
#> [1] 0
#> 
#> $rows[[2]]$monthend
#> [1] 0
#> 
#> $rows[[2]]$monthsin
#> [1] 0.8660254
#> 
#> $rows[[2]]$monthcos
#> [1] -0.5
#> 
#> $rows[[2]]$dowsin
#> [1] -0.9749279
#> 
#> $rows[[2]]$dowcos
#> [1] -0.2225209
#> 
#> 
#> 
#> $n
#> [1] 2
#> 
#> $nweekend
#> [1] 1
#> 
#> $meandoy
#> [1] 80
#> 
#> $meanmonthsin
#> [1] 0.9330127
#>