estimateGLRNbHook: Hook function for in-control mean estimation

Description Usage Details Value Author(s) See Also Examples

Description

Allows the user to specify his own estimation routine for the in-control mean of algo.glrpois Needs to work for GLRNbHook

Usage

1

Details

This hook function allows the user to customize the behaviour of the algorithm.

Value

A list

mod

resulting model of a call of glm.nb

range

vector of length as range containing the predicted values

Author(s)

M. Hoehle

See Also

algo.glrnb and algo.glrpois

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Not run: 
estimateGLRNbHook <- function() {
  #Fetch control object from parent
  control <- parent.frame()$control
  #The period
  p <- parent.frame()$disProgObj$freq
  #Current range to perform surveillance on
  range <- parent.frame()$range

  #Define training & test data set (the rest)
  train <- 1:(range[1]-1)
  test <- range
  
  #Perform an estimation based on all observations before timePoint
  #Event better - don't do this at all in the algorithm - force
  #user to do it himself - coz its a model selection problem
  data <- data.frame(y=parent.frame()$disProgObj$observed[t],t=train)
  #Build the model equation
  formula <- "y ~ 1 "
  if (control$mu0Model$trend) { formula <- paste(formula," + t",sep="") }
  for (s in 1:control$mu0Model$S) {
    formula <- paste(formula,"+cos(2*",s,"*pi/p*t)+ sin(2*",s,"*pi/p*t)",sep="")
  }
  #Fit the GLM
  m <- eval(substitute(glm.nb(form,data=data),
                      list(form=as.formula(formula))))

  #Predict mu_{0,t}
  return(as.numeric(predict(m,newdata=data.frame(t=range),type="response")))
}

## End(Not run)

jimhester/surveillance documentation built on May 19, 2019, 10:33 a.m.