Skip to contents

Data fit using glmer from lme4 with family poisson to fit the dataset with the given formula.

Usage

fit_attrib(
  data,
  response,
  fixef,
  ranef,
  dist_family = "poisson",
  offset = NULL
)

Arguments

data

The observed data to be fitted.

response

The response

fixef

The fixed effects

ranef

The random effects

dist_family

Family

offset

The offsets.

Value

The model fit of the data with additional attributes offset, response and fit_fix. Offset and response are the same as in the input and fit_fix is the linear model of the fix effects.

For more details see the help vignette: vignette("intro", package="attrib")

Examples


response <- "deaths_n"

fixef <- "ili_isoweekmean7_13_pr100 +
  sin(2 * pi * (isoweek - 1) / 52) +
  cos(2 * pi * (isoweek - 1) / 52)"
ranef <- " (ili_isoweekmean7_13_pr100| season)"
offset <- "log(pop_jan1_n)"

data <- attrib::data_fake_attrib_nation

fit_attrib(data = data, response = response, fixef = fixef, ranef = ranef, offset = offset)
#> boundary (singular) fit: see help('isSingular')
#> Generalized linear mixed model fit by maximum likelihood (Laplace
#>   Approximation) [glmerMod]
#>  Family: poisson  ( log )
#> Formula: deaths_n ~ ili_isoweekmean7_13_pr100 + sin(2 * pi * (isoweek -  
#>     1)/52) + cos(2 * pi * (isoweek - 1)/52) + offset(log(pop_jan1_n)) +  
#>     (ili_isoweekmean7_13_pr100 | season)
#>    Data: data
#>       AIC       BIC    logLik  deviance  df.resid 
#>  5584.788  5615.256 -2785.394  5570.788       567 
#> Random effects:
#>  Groups Name                      Std.Dev. Corr
#>  season (Intercept)               0.000000     
#>         ili_isoweekmean7_13_pr100 0.003655  NaN
#> Number of obs: 574, groups:  season, 11
#> Fixed Effects:
#>                    (Intercept)       ili_isoweekmean7_13_pr100  
#>                      -8.800873                        0.062266  
#> sin(2 * pi * (isoweek - 1)/52)  cos(2 * pi * (isoweek - 1)/52)  
#>                      -0.005386                        0.033550  
#> optimizer (Nelder_Mead) convergence code: 0 (OK) ; 0 optimizer warnings; 1 lme4 warnings