Takes a time series and fits a robust regression model using the method described by Serfling (1963) in 'Methods for Current Statistical Analysis of Excess Pneumonia-Influenza Deaths'. Helper function 'serf.design' constructs the design matrix according to parameters 'trend.poly', 'harmonic', and 'period'. See serf.fit function for example on how to fit standard model.
1 2 3 4 5 | serf.robust(t1 = 1, t2 = length(ts), t3 = min(t2 + 1, length(ts)),
t4 = min(t2 + 1, length(ts)), trend.poly = 1, harmonic = c(1, 2, 3),
covar = NULL, method = "a", c = 2.1, thresh = 2.1, max.iter = 10,
period = g.period, ylim = range(ts[t1:t4]), plot = TRUE, plotagg = 0,
main = g.main, output = TRUE, ts = g.ts)
|
t1 |
is the integer index of the parameter 'ts' where model fitting begins; defaults to 1 |
t2 |
is the integer index of the parameter 'ts' where model fitting ends; defaults to length(ts) |
t3 |
is the integer index of the time series where fitted values begin; defaults to min(t2+1,length(ts)) |
t4 |
is the integer index of the time series where fitted values end; defaults to min(t2+1,length(ts)) |
trend.poly |
is specified as an integer vector representing the degrees of the polynomial terms to be included; defaults to 1 i.e. single linear trend term |
harmonic |
is also specified as an integer vector representing fractional multiples of the period e.g. 'harmonic=c(1,2)' specifies two harmonic pairs (two sine terms and two cosine terms) of one period and one half-period respectively |
covar |
adds additional covariance factors but this feature not currently implemented; defaults to NULL |
thresh |
is a numeric value specifying the epidemic threshold as a multiple of the residual standard deviation; defaults to 2.5 |
max.iter |
numeric value indicating the maximum number of iterations; default set to 10 |
period |
numeric value; defaults to 52.2 |
ylim |
range of y-axis for plotting |
plot |
logical, generates plot of times series with threshold and epidemic observations; defaults to TRUE |
output |
logical, outputs fitted values and epidemic observations; default set to TRUE |
ts |
vector; response vector of numeric values representing the time series to be modeled. By default this is set to 'g.ts' the global time series which MUST be specified by the user before calling this function |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.