This function configures a very simple poisson count model and using:
Usage
gam_poisson_model_fn(window, ..., knots_fn = ~gam_knots(.x, window, ...))Arguments
- window
controls the knot spacing in the GAM (if the default)
- ...
Named arguments passed on to
gam_knotskalternative to
window, ifkis given then the behaviour of the knots will be similar to the defaultmgcv::s(...,k=...)parameter.
- knots_fn
a function that takes the data as an input and returns a set of integers as time points for GAM knots, for
s(time)term. The default here provides a roughly equally spaced grid determined bywindow, by a user supplied function could do anything. The input this function is the raw dataframe of data that will be considered for one model fit. It is guaranteed to have at least atimeandcountcolumn. It is possible to
Details
count ~ s(time, bs = "cr", k = length(kts))
The control of knot positions is defined by the knots_fn and window
parameters.
Examples
model_fn = gam_poisson_model_fn(14)
fit = model_fn(test_poisson_rt() %>% dplyr::ungroup())
summary(fit)
#>
#> Family: quasipoisson
#> Link function: log
#>
#> Formula:
#> count ~ s(time, bs = "cr", k = length(kts))
#>
#> Parametric coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 7.0884 0.1017 69.7 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Approximate significance of smooth terms:
#> edf Ref.df F p-value
#> s(time) 6.512 6.908 133.9 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> R-sq.(adj) = 0.892 Deviance explained = 96.6%
#> -REML = 249.2 Scale est. = 127.45 n = 81
