data("fooepidata")
summary(fooepidata)
# fit an overall constant baseline hazard rate
fit1 <- twinSIR(~ B1 + B2 + cox(z2), data = fooepidata, keep.data = TRUE)
fit1
summary(fit1)
# fit a piecewise constant baseline hazard rate with 3 intervals using
# _un_penalized ML and estimated coefs from fit1 as starting values
fit2 <- twinSIR(~ B1 + B2 + cox(z2), data = fooepidata, nIntervals = 3,
optim.args = list(par=c(coef(fit1)[1:2],rep(coef(fit1)[3],3),coef(fit1)[4])))
fit2
summary(fit2)
# fit a piecewise constant baseline hazard rate with 9 intervals
# using _penalized_ ML and estimated coefs from fit1 as starting values
fit3 <- twinSIR(~ B1 + B2 + cox(z2), data = fooepidata, nIntervals = 9,
lambda.smooth = 0.1, penalty = 1, optim.args = list(
par=c(coef(fit1)[1:2], rep(coef(fit1)[3],9), coef(fit1)[4])))
fit3
summary(fit3)
# plot of the 9 log-baseline levels
plot(x=fit3$intervals, y=coef(fit3)[c(3,3:11)], type="S")
### -> for more sophisticated intensity plots, see 'plot.twinSIR'
plot(fit3)
### TODO (@Michael): Analysis of the 1861 hagelloch measles epidemic
#data(hagelloch)
#m <- twinSIR(~c1 + c2 + household + local1, data = hagelloch)
#FIXME: what is "local1"? what is "local"? what about c1, c2, household?
# describe this on the help page of data(hagelloch)?
#FIXME: there are no functions to generate c1 and c2 in attr(hagelloch, "f")
# which implies that the simulate-method doesn't work for this model
#summary(m)
Run the code above in your browser using DataLab