Description Usage Arguments Details Value Examples
View source: R/CFR_estimation.R
This function implements an EM algorithm to estimate the relative case fatality ratio between two groups when reporting rates are time-varying and deaths are lagged because of survival time.
1 2 |
assumed.nu |
a vector of probabilities corresponding to the survival distribution, i.e. nu[i]=Pr(surviving i days | fatal case) |
alpha.start.values |
a vector starting values for the reporting rate parameter of the GLM model. This must have length which corresponds to one less than the number of unique integer values of full.dat[,"new.times"]. |
full.data |
A matrix of observed data. See description below. |
max.iter |
The maximum number of iterations for the EM algorithm and the accompanying SEM algorithm (if used). |
verb |
An indicator for whether the function should print results as it runs. |
tol |
A tolerance to use to test for convergence of the EM algorithm. |
SEM.var |
If TRUE, the SEM algorithm will be run in addition to the EM algorithm to calculate the variance of the parameter estimates. |
The data matrix full.data must have the following columns:
a 1 or a 2 indicating which of the two groups, j, the observation is for.
an integer value representing the time, t, of observation.
the count of recovered cases with onset at time t in group j.
the count of deaths which occurred at time t in groupo j (note that these deaths did not have disease onset at time t but rather died at time t).
the total cases at t, j, or the sum of R and D columns.
A list with the following elements
the naive estimate of the relative case fatality ratio
the reporting-rate-adjusted estimate of the relative case fatality ratio
the lag-adjusted estimate of the relative case fatality ratio
the variance for the log-scale lag-adjusted estimator taken from the final M-step
the Supplemented EM algorithm variance for the log-scale lag-adjusted estimator
a vector of the EM algorithm iterates of the lag-adjusted relative CFR estimates
the number of iterations needed for the EM algorithm to converge
indicator for convergence of the EM algorithm. 0 indicates all parameters converged within max.iter iterations. 1 indicates that the estimate of the relative case fatality ratio converged but other did not. 2 indicates that the relative case fatality ratio did not converge.
indicator for convergence of SEM algorithm. Same scheme as EMconv.
the coefficient estimates for the model
a matrix with all of the coefficient estimates, at each EM iteration
the DM matrix from the SEM algorithm
a vector showing how many iterations it took for the variance component to converge in the SEM algorithm
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 |
## This is code from the CFR vignette provided in the documentation.
data(simulated.outbreak.deaths)
min.cases <- 10
N.1 <- simulated.outbreak.deaths[1:60, "N"]
N.2 <- simulated.outbreak.deaths[61:120, "N"]
first.t <- min(which(N.1 > min.cases & N.2 > min.cases))
last.t <- max(which(N.1 > min.cases & N.2 > min.cases))
idx.for.Estep <- first.t:last.t
new.times <- 1:length(idx.for.Estep)
simulated.outbreak.deaths <- cbind(simulated.outbreak.deaths, new.times = NA)
simulated.outbreak.deaths[c(idx.for.Estep, idx.for.Estep + 60), "new.times"] <- rep(new.times, + 2)
assumed.nu = c(0, 0.3, 0.4, 0.3)
alpha.start <- rep(0, 22)
## caution! this next line may take several minutes (5-10, depanding on
## the speed of your machine) to run.
## Not run: cfr.ests <- EMforCFR(assumed.nu = assumed.nu,
alpha.start.values = alpha.start,
full.data = simulated.outbreak.deaths,
verb = FALSE,
SEM.var = TRUE,
max.iter = 500,
tol = 1e-05)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.