R/fluglm.R
fluglm.Rd
Similar to serflm, but allows for more specifications.
fluglm(data=NULL, outc=NULL, season, viral, time=NULL, period=52, echo=F, poly=T, model_form='none', int_type="ci", alpha=0.05, offset, glmnb=F, ...)
data | A dataframe class object, must contain time variable, epidemic indicator, and measure of influenza morbidity |
---|---|
outc | an unquoted name of a column in data which corresponds to the outcome variable of interest |
season | Either 'T', where the epidemic baseline model will be created assuming time variable is a date, and Oct-May is epidemic season, or the name of a column which is a logical vector flagging a given week as epidemic or not |
viral | a string vector naming 1 or more viral specimens |
time | an unquoted name of a column in data object, must be a numeric/integer class variable in dataframe which corresponds to a unit of time, must be unique (i.e. non-repeating) |
period | a numeric vector indicating period length, i.e. 52 weeks in year |
echo | A logical, if T will print variables used in model. |
poly | A logical, if T will include a quadratic, cubic, quartic and quintic term. |
model_form | An object of type formula, allowing for user-specified model to be passed on to glm(). Default missing. |
int_type | Specifies type of upper interval to be output, currently only allows for confidence intervals. Prediction intervals to be added, but are only approximate for Poisson families. |
alpha | The threshold for CI interval, default is 0.05 (one-sided). |
offset | Specify if offset term to be used, must specify log(object) |
glmnb | Logical, if True will run a negative binomial model using MASS::nb.glm |
... | other options passed on to glm model (e.g. family=poisson, see ?glm) |
an object of class data.frame, fit, upper and lower confidence bounds
Thompson WW1, Weintraub E, Dhankhar P, Cheng PY, Brammer L, Meltzer MI, Bresee JS, Shay DK. Estimates of US influenza-associated deaths made using four different methods. Influenza Other Respir Viruses. 2009 Jan;3(1):37-49. /urlhttps://www.ncbi.nlm.nih.gov/pubmed/19453440
require(flumodelr) fludta <- flumodelr::fludta flu_fit <- fluglm(fludta, outc = fludeaths, time = week_in_order, season=epi) head(flu_fit)#> # A tibble: 6 x 6 #> flu_pred flu_pred_upr flu_pred_lwr flu_base flu_base_upr flu_base_lwr #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 519. 541. 496. 371. 394. 349. #> 2 537. 559. 515. 376. 399. 353. #> 3 554. 576. 532. 381. 404. 357. #> 4 571. 593. 549. 385. 409. 361. #> 5 586. 608. 565. 390. 414. 365. #> 6 600. 622. 579. 395. 419. 370.