Title: | Confidence Intervals with Poisson Double Sampling |
---|---|
Description: | Functions to create confidence intervals for ratios of Poisson rates under misclassification using double sampling. |
Authors: | David Kahle [aut, cre], Phil Young [aut], Dean Young [aut] |
Maintainer: | David Kahle <[email protected]> |
License: | GPL-2 |
Version: | 1.1 |
Built: | 2024-11-06 03:55:49 UTC |
Source: | https://github.com/dkahle/poisdoublesamp |
Compute the marginal MLE of the ratio of two Poisson rates in a two-sample Poisson rate problem with misclassified data given fallible and infallible datasets.
approxMargMLE(data, N1, N2, N01, N02, l = 0, u = 1000, out = c("par", "all"), tol = 1e-10)
approxMargMLE(data, N1, N2, N01, N02, l = 0, u = 1000, out = c("par", "all"), tol = 1e-10)
data |
the vector of counts of the fallible data (z11, z12, z21, z22) followed by the infallible data (m011, m012, m021, m022, y01, y02) |
N1 |
the opportunity size of group 1 for the fallible data |
N2 |
the opportunity size of group 2 for the fallible data |
N01 |
the opportunity size of group 1 for the infallible data |
N02 |
the opportunity size of group 2 for the infallible data |
l |
the lower end of the range of possible phi's (for optim) |
u |
the upper end of the range of possible phi's (for optim) |
out |
"par" or "all" (for the output of optim) |
tol |
tolerance parameter for the rmle EM algorithm |
a named vector containing the marginal mle of phi
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) fullMLE(data, N1, N2, N01, N02) margMLE(data, N1, N2, N01, N02) approxMargMLE(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) fullMLE(data, N1, N2, N01, N02) # margMLE(data, N1, N2, N01, N02) # ~1 min approxMargMLE(data, N1, N2, N01, N02) ## End(Not run)
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) fullMLE(data, N1, N2, N01, N02) margMLE(data, N1, N2, N01, N02) approxMargMLE(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) fullMLE(data, N1, N2, N01, N02) # margMLE(data, N1, N2, N01, N02) # ~1 min approxMargMLE(data, N1, N2, N01, N02) ## End(Not run)
Compute the profile MLE confidence interval of the ratio of two Poisson rates in a two-sample Poisson rate problem with misclassified data given fallible and infallible datasets. This uses a C++ implemention of the EM algorithm.
approxMargMLECI(data, N1, N2, N01, N02, conf.level = 0.95, l = 0.001, u = 1000, tol = 1e-10)
approxMargMLECI(data, N1, N2, N01, N02, conf.level = 0.95, l = 0.001, u = 1000, tol = 1e-10)
data |
the vector of counts of the fallible data (z11, z12, z21, z22) followed by the infallible data (m011, m012, m021, m022, y01, y02) |
N1 |
the opportunity size of group 1 for the fallible data |
N2 |
the opportunity size of group 2 for the fallible data |
N01 |
the opportunity size of group 1 for the infallible data |
N02 |
the opportunity size of group 2 for the infallible data |
conf.level |
confidence level of the interval |
l |
the lower end of the range of possible phi's (for optim) |
u |
the upper end of the range of possible phi's (for optim) |
tol |
tolerance used in the EM algorithm to declare convergence |
a named vector containing the marginal mle of phi
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) ## End(Not run)
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) ## End(Not run)
Compute the MLEs of a two-sample Poisson rate problem with misclassified data given fallible and infallible datasets.
fullMLE(data, N1, N2, N01, N02)
fullMLE(data, N1, N2, N01, N02)
data |
the vector of counts of the fallible data (z11, z12, z21, z22) followed by the infallible data (m011, m012, m021, m022, y01, y02) |
N1 |
the opportunity size of group 1 for the fallible data |
N2 |
the opportunity size of group 2 for the fallible data |
N01 |
the opportunity size of group 1 for the infallible data |
N02 |
the opportunity size of group 2 for the infallible data |
These are the closed-form expressions for the MLEs.
a named vector containing the mles of each of the parameters (phi, la12, la21, la22, th1, and th2)
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) fullMLE(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) fullMLE(data, N1, N2, N01, N02) ## End(Not run)
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) fullMLE(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) fullMLE(data, N1, N2, N01, N02) ## End(Not run)
Compute the marginal MLE of the ratio of two Poisson rates in a two-sample Poisson rate problem with misclassified data given fallible and infallible datasets.
margMLE(data, N1, N2, N01, N02, l = 0.001, u = 1000, out = c("par", "all"))
margMLE(data, N1, N2, N01, N02, l = 0.001, u = 1000, out = c("par", "all"))
data |
the vector of counts of the fallible data (z11, z12, z21, z22) followed by the infallible data (m011, m012, m021, m022, y01, y02) |
N1 |
the opportunity size of group 1 for the fallible data |
N2 |
the opportunity size of group 2 for the fallible data |
N01 |
the opportunity size of group 1 for the infallible data |
N02 |
the opportunity size of group 2 for the infallible data |
l |
the lower end of the range of possible phi's (for optim) |
u |
the upper end of the range of possible phi's (for optim) |
out |
"par" or "all" (for the output of optim) |
a named vector containing the marginal mle of phi
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) fullMLE(data, N1, N2, N01, N02) margMLE(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) fullMLE(data, N1, N2, N01, N02) margMLE(data, N1, N2, N01, N02) ## End(Not run)
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) fullMLE(data, N1, N2, N01, N02) margMLE(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) fullMLE(data, N1, N2, N01, N02) margMLE(data, N1, N2, N01, N02) ## End(Not run)
Compute the marginal MLE confidence interval of the ratio of two Poisson rates in a two-sample Poisson rate problem with misclassified data given fallible and infallible datasets.
margMLECI(data, N1, N2, N01, N02, conf.level = 0.95, l = 1e-10, u = 1e+10)
margMLECI(data, N1, N2, N01, N02, conf.level = 0.95, l = 1e-10, u = 1e+10)
data |
the vector of counts of the fallible data (z11, z12, z21, z22) followed by the infallible data (m011, m012, m021, m022, y01, y02) |
N1 |
the opportunity size of group 1 for the fallible data |
N2 |
the opportunity size of group 2 for the fallible data |
N01 |
the opportunity size of group 1 for the infallible data |
N02 |
the opportunity size of group 2 for the infallible data |
conf.level |
confidence level of the interval |
l |
the lower end of the range of possible phi's (for optim) |
u |
the upper end of the range of possible phi's (for optim) |
a named vector containing the lower and upper bounds of the confidence interval
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) ## End(Not run)
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) ## End(Not run)
Functions to create confidence intervals for ratios of Poisson rates under misclassification using double sampling.
Compute the profile MLE confidence interval of the ratio of two Poisson rates in a two-sample Poisson rate problem with misclassified data given fallible and infallible datasets. This uses a C++ implemention of the EM algorithm.
profMLECI(data, N1, N2, N01, N02, conf.level = 0.95, l = 0.001, u = 1000, tol = 1e-10)
profMLECI(data, N1, N2, N01, N02, conf.level = 0.95, l = 0.001, u = 1000, tol = 1e-10)
data |
the vector of counts of the fallible data (z11, z12, z21, z22) followed by the infallible data (m011, m012, m021, m022, y01, y02) |
N1 |
the opportunity size of group 1 for the fallible data |
N2 |
the opportunity size of group 2 for the fallible data |
N01 |
the opportunity size of group 1 for the infallible data |
N02 |
the opportunity size of group 2 for the infallible data |
conf.level |
confidence level of the interval |
l |
the lower end of the range of possible phi's (for optim) |
u |
the upper end of the range of possible phi's (for optim) |
tol |
tolerance used in the EM algorithm to declare convergence |
a named vector containing the marginal mle of phi
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) ## End(Not run)
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) ## End(Not run)
Compute the Wald confidence interval of a two-sample Poisson rate with misclassified data given fallible and infallible datasets.
waldCI(data, N1, N2, N01, N02, conf.level = 0.95)
waldCI(data, N1, N2, N01, N02, conf.level = 0.95)
data |
the vector of counts of the fallible data (z11, z12, z21, z22) followed by the infallible data (m011, m012, m021, m022, y01, y02) |
N1 |
the opportunity size of group 1 for the fallible data |
N2 |
the opportunity size of group 2 for the fallible data |
N01 |
the opportunity size of group 1 for the infallible data |
N02 |
the opportunity size of group 2 for the infallible data |
conf.level |
confidence level of the interval |
a named vector containing the lower and upper bounds of the confidence interval
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) ## End(Not run)
## Not run: # small example z11 <- 34; z12 <- 35; N1 <- 10; z21 <- 22; z22 <- 31; N2 <- 10; m011 <- 9; m012 <- 1; y01 <- 3; N01 <- 3; m021 <- 8; m022 <- 8; y02 <- 2; N02 <- 3; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) # big example : z11 <- 477; z12 <- 1025; N1 <- 16186; z21 <- 255; z22 <- 1450; N2 <- 18811; m011 <- 38; m012 <- 90; y01 <- 15; N01 <- 1500; m021 <- 41; m022 <- 200; y02 <- 9; N02 <- 2500; data <- c(z11, z12, z21, z22, m011, m012, m021, m022, y01, y02) waldCI(data, N1, N2, N01, N02) margMLECI(data, N1, N2, N01, N02) profMLECI(data, N1, N2, N01, N02) approxMargMLECI(data, N1, N2, N01, N02) ## End(Not run)