Is it possible to include the product of two smooth terms in the mgcv gam model

I have had great success using the gamut to model seasonality for given time series. My latest model clearly shows a weekly pattern in addition to seasonal changes. While the weekly sample itself is very stable throughout the year, its amplitude also varies with the time of year. Therefore, ideally, I would like to model my data as:

y ~ f(day in year) + g(day in year) * h(day in week)

where f, gand hare cyclic smooth functions inmgcv

gam(
  y ~ s(day_in_year, k=52, bs='cc') 
  + s(day_in_year, k=52, bs='cc'):s(day_in_week, k=5, bs='cc')
  , knots=list(
    day_in_year=c(0, 356)
    , day_in_week=c(0,7)
  )
  , data = data
)

, NA/NaN argument. te(day_in_year, day_in_week, k=c(52, 5), bs='cc'), , , , .

, ?

+4
2

, !

, .

te - , ti. , te . . k = 52 , k = 5 , 52 * 5 - 1 . , .

, mgcv GAM : * . te ti.

, , ""? ? ? , . .

, , 2006 . GAM , , / GAM (, ) 4, .

, . Kronecker, te/ti, .

s(x) - g, , . g , f(x) - . , , .

g1 5 g2 10 , ( ) 4 9 , g1:g2 36 , - g1 g2.


, , , 2 3? k = 52 day_in_year. , , k = 30.

, .

1: GCV . method = "REML". GCV .

2: GCV, . gamma gam . gamma = 1.5 .


?

, day_in_year = c(0, 365)?

+2

, , :

  • ,
  • ,
  • , .

. , .

y ~ f ( ) + g ( ) * h ( )

, * + . , , - . :, , .

( ). :

gam(y ~ te(day_of_year, day_of_week, k = c(20, 6), bs = c("cc", "cc")),
    data = foo, method = "REML", knots = knots)

. :

knots <- list(day_of_year = c(0.5, 366.5),
              day_of_week = c(0.5, 7.5)

, .

, ti() smooths

gam(y ~ ti(day_of_year, bs = "cc", k = 12) + ti(day_of_week, bs = "cc", k = 6) + 
      te(day_of_year, day_of_week, k = c(12, 6), bs = c("cc", "cc")),
    data = foo, method = "REML", knots = knots)

k, gam.check().

. , , - holiday + holiday. ; , , , day_of_week, , - , .

/ , .

, te() , , ; , . . , - .

+1

Source: https://habr.com/ru/post/1540302/


All Articles