cosinor: Cosinor regression model for detecting seasonality

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/cosinor.R

Description

Fits a cosinor model as part of a generalized linear model.

Usage

1
2
cosinor(formula, date, data, family=gaussian() ,alpha=0.05, cycles=1,
               rescheck=FALSE, type='daily', offsetmonth=FALSE, offsetpop=NULL, text=TRUE)

Arguments

formula

regression formula.

date

a date variable if type=“daily”, or an integer between 1 and 12 if type=“monthly”.

data

data set as a data frame.

family

a description of the error distribution and link function to be used in the model. Available link functions: identity, log, logit, cloglog. Note, it must have the parentheses.

alpha

significance level, set to 0.05 (default).

cycles

number of seasonal cycles per year.

rescheck

plot the residual checks (TRUE/FALSE), see seasrescheck.

type

“daily” for daily data (default), or “monthly” for monthly data.

offsetmonth

include an offset to account for the uneven number of days in the month (TRUE/FALSE). Should be used for monthly counts (with family=poisson()).

offsetpop

include an offset for the population (optional), this should be a variable in the data frame.

text

add explanatory text to the returned phase value (TRUE) or return a number (FALSE). Passed to the invyrfraction function.

Details

The cosinor model captures a seasonal pattern using a sinusoid. It is therefore suitable for relatively simple seasonal patterns that are symmetric and stationary. The default is to fit an annual seasonal pattern (cycle=1), but other frequencies are possible (e.g., twice per year: cycle=2). The model is fitted using a sine and cosine term that together describe the sinusoid. These parameters are added to a generalized linear model, so the model can be fitted to a range of dependent data (e.g., Normal, Poisson, Binomial). Unlike the nscosinor model, the cosinor model can be applied to unequally spaced data.

Value

Returns an object of class “Cosinor” with the following parts:

call

the original call to the cosinor function.

glm

an object of class glm (see glm).

fitted

fitted values for intercept and cosinor only (ignoring other independent variables).

fitted.plus

standard fitted values, including all other independent variables.

residuals

residuals.

date

date variable (in Date format when type=‘daily’).

Author(s)

Adrian Barnett a.barnett<at>qut.edu.au

References

Barnett, A.G., Dobson, A.J. (2010) Analysing Seasonal Health Data. Springer.

See Also

summary.Cosinor, plot.Cosinor

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## cardiovascular disease data (offset based on number of days in... 
## ...the month scaled to an average month length)
data(CVD)
res = cosinor(cvd~1, date=month, data=CVD, type='monthly',
              family=poisson(), offsetmonth=TRUE)
summary(res)
# stillbirth data
data(stillbirth)
res = cosinor(stillborn~1, date=dob, data=stillbirth,
              family=binomial(link='cloglog'))
summary(res)
plot(res)

season documentation built on May 2, 2019, 5:22 p.m.