-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
503 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.Rhistory | ||
.Rproj.user |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
\name{exposure.SIR} | ||
\alias{exposure.SIR} | ||
%- Also NEED an '\alias' for EACH other topic documented here. | ||
\title{ | ||
A Capitalized Title (ideally limited to 65 characters) | ||
} | ||
\description{ | ||
%% ~~ A concise (1-5 lines) description of what the function does. ~~ | ||
} | ||
\usage{ | ||
exposure.SIR(Time, state, Pars) | ||
} | ||
%- maybe also 'usage' for other objects documented here. | ||
\arguments{ | ||
\item{Time}{ | ||
%% ~~Describe \code{Time} here~~ | ||
} | ||
\item{state}{ | ||
%% ~~Describe \code{state} here~~ | ||
} | ||
\item{Pars}{ | ||
%% ~~Describe \code{Pars} here~~ | ||
} | ||
} | ||
\details{ | ||
%% ~~ If necessary, more details than the description above ~~ | ||
} | ||
\value{ | ||
%% ~Describe the value returned | ||
%% If it is a LIST, use | ||
%% \item{comp1 }{Description of 'comp1'} | ||
%% \item{comp2 }{Description of 'comp2'} | ||
%% ... | ||
} | ||
\references{ | ||
%% ~put references to the literature/web site here ~ | ||
} | ||
\author{ | ||
%% ~~who you are~~ | ||
} | ||
\note{ | ||
%% ~~further notes~~ | ||
} | ||
|
||
%% ~Make other sections like Warning with \section{Warning }{....} ~ | ||
|
||
\seealso{ | ||
%% ~~objects to See Also as \code{\link{help}}, ~~~ | ||
} | ||
\examples{ | ||
##---- Should be DIRECTLY executable !! ---- | ||
##-- ==> Define data, use random, | ||
##-- or standard data sets, see data(). | ||
|
||
## The function is currently defined as | ||
function (Time, state, Pars) | ||
{ | ||
with(as.list(c(Time, state, Pars)), { | ||
S <- c(S1, S2) | ||
I <- c(I1, I2) | ||
R <- c(R1, R2) | ||
N <- c(N1, N2) | ||
beta <- (1 - epsilon) * outer(activities, activities)/sum(c(N1, | ||
N2) * activities) + epsilon * activities/c(N1, N2) * | ||
diag(2) | ||
beta <- beta/scaling.factor | ||
dS <- -(beta \%*\% I) * S | ||
dI <- (beta \%*\% I) * S - gam * I | ||
dR <- gam * I | ||
return(list(c(dS, dI, dR))) | ||
}) | ||
} | ||
} | ||
% Add one or more standard keywords, see file 'KEYWORDS' in the | ||
% R documentation directory (show via RShowDoc("KEYWORDS")): | ||
% \keyword{ ~kwd1 } | ||
% \keyword{ ~kwd2 } | ||
% Use only one keyword per line. | ||
% For non-standard keywords, use \concept instead of \keyword: | ||
% \concept{ ~cpt1 } | ||
% \concept{ ~cpt2 } | ||
% Use only one concept per line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
\name{finalSizeExample} | ||
\alias{finalSizeExample} | ||
\docType{data} | ||
\title{ | ||
A Capitalized Title for the Data Set | ||
} | ||
\description{ | ||
%% ~~ A concise (1-5 lines) description of the dataset. ~~ | ||
} | ||
\usage{data("finalSizeExample")} | ||
\format{ | ||
The format is: | ||
num [1:2] 233224 102557 | ||
} | ||
\details{ | ||
%% ~~ If necessary, more details than the __description__ above ~~ | ||
} | ||
\source{ | ||
%% ~~ reference to a publication or URL from which the data were obtained ~~ | ||
} | ||
\references{ | ||
%% ~~ possibly secondary sources and usages ~~ | ||
} | ||
\examples{ | ||
data(finalSizeExample) | ||
## maybe str(finalSizeExample) ; plot(finalSizeExample) ... | ||
} | ||
\keyword{datasets} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
\name{getFinalSize} | ||
\alias{getFinalSize} | ||
%- Also NEED an '\alias' for EACH other topic documented here. | ||
\title{ | ||
A Capitalized Title (ideally limited to 65 characters) | ||
} | ||
\description{ | ||
%% ~~ A concise (1-5 lines) description of what the function does. ~~ | ||
} | ||
\usage{ | ||
getFinalSize(vacTime, vacPortion, popSize, R0, recoveryRate, contactRatio, contactWithinGroup, suscRatio) | ||
} | ||
%- maybe also 'usage' for other objects documented here. | ||
\arguments{ | ||
\item{vacTime}{ | ||
%% ~~Describe \code{vacTime} here~~ | ||
} | ||
\item{vacPortion}{ | ||
%% ~~Describe \code{vacPortion} here~~ | ||
} | ||
\item{popSize}{ | ||
%% ~~Describe \code{popSize} here~~ | ||
} | ||
\item{R0}{ | ||
%% ~~Describe \code{R0} here~~ | ||
} | ||
\item{recoveryRate}{ | ||
%% ~~Describe \code{recoveryRate} here~~ | ||
} | ||
\item{contactRatio}{ | ||
%% ~~Describe \code{contactRatio} here~~ | ||
} | ||
\item{contactWithinGroup}{ | ||
%% ~~Describe \code{contactWithinGroup} here~~ | ||
} | ||
\item{suscRatio}{ | ||
%% ~~Describe \code{suscRatio} here~~ | ||
} | ||
} | ||
\details{ | ||
%% ~~ If necessary, more details than the description above ~~ | ||
} | ||
\value{ | ||
%% ~Describe the value returned | ||
%% If it is a LIST, use | ||
%% \item{comp1 }{Description of 'comp1'} | ||
%% \item{comp2 }{Description of 'comp2'} | ||
%% ... | ||
} | ||
\references{ | ||
%% ~put references to the literature/web site here ~ | ||
} | ||
\author{ | ||
%% ~~who you are~~ | ||
} | ||
\note{ | ||
%% ~~further notes~~ | ||
} | ||
|
||
%% ~Make other sections like Warning with \section{Warning }{....} ~ | ||
|
||
\seealso{ | ||
%% ~~objects to See Also as \code{\link{help}}, ~~~ | ||
} | ||
\examples{ | ||
##---- Should be DIRECTLY executable !! ---- | ||
##-- ==> Define data, use random, | ||
##-- or standard data sets, see data(). | ||
|
||
## The function is currently defined as | ||
function (vacTime, vacPortion, popSize, R0, recoveryRate, contactRatio, | ||
contactWithinGroup, suscRatio) | ||
{ | ||
Isim1 <- c(0, 0) | ||
Rsim1 <- c(0, 0) | ||
if (vacTime > 0) { | ||
sim1 <- sim.exposure.SIR(Rinit = c(0, 0), Iinit = c(0, | ||
0), Vinit = c(0, 0), tm = vacTime, N = popSize, R0 = R0, | ||
gam = recoveryRate, a = c(1, contactRatio), eps = contactWithinGroup, | ||
q = c(1, suscRatio)) | ||
Isim1 <- as.numeric(sim1[nrow(sim1), c("I1", "I2")]) | ||
Rsim1 <- as.numeric(sim1[nrow(sim1), c("R1", "R2")]) | ||
} | ||
getFinalSizeAnalytic(Rinit = Rsim1, Iinit = Isim1, Vinit = popSize * | ||
vacPortion, N = popSize, R0 = R0, a = c(1, contactRatio), | ||
eps = contactWithinGroup, q = c(1, suscRatio)) | ||
} | ||
} | ||
% Add one or more standard keywords, see file 'KEYWORDS' in the | ||
% R documentation directory (show via RShowDoc("KEYWORDS")): | ||
% \keyword{ ~kwd1 } | ||
% \keyword{ ~kwd2 } | ||
% Use only one keyword per line. | ||
% For non-standard keywords, use \concept instead of \keyword: | ||
% \concept{ ~cpt1 } | ||
% \concept{ ~cpt2 } | ||
% Use only one concept per line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
\name{getFinalSizeAnalytic} | ||
\alias{getFinalSizeAnalytic} | ||
%- Also NEED an '\alias' for EACH other topic documented here. | ||
\title{ | ||
A Capitalized Title (ideally limited to 65 characters) | ||
} | ||
\description{ | ||
%% ~~ A concise (1-5 lines) description of what the function does. ~~ | ||
} | ||
\usage{ | ||
getFinalSizeAnalytic(Rinit, Iinit, Vinit, N, R0, a, eps, q) | ||
} | ||
%- maybe also 'usage' for other objects documented here. | ||
\arguments{ | ||
\item{Rinit}{ | ||
%% ~~Describe \code{Rinit} here~~ | ||
} | ||
\item{Iinit}{ | ||
%% ~~Describe \code{Iinit} here~~ | ||
} | ||
\item{Vinit}{ | ||
%% ~~Describe \code{Vinit} here~~ | ||
} | ||
\item{N}{ | ||
%% ~~Describe \code{N} here~~ | ||
} | ||
\item{R0}{ | ||
%% ~~Describe \code{R0} here~~ | ||
} | ||
\item{a}{ | ||
%% ~~Describe \code{a} here~~ | ||
} | ||
\item{eps}{ | ||
%% ~~Describe \code{eps} here~~ | ||
} | ||
\item{q}{ | ||
%% ~~Describe \code{q} here~~ | ||
} | ||
} | ||
\details{ | ||
%% ~~ If necessary, more details than the description above ~~ | ||
} | ||
\value{ | ||
%% ~Describe the value returned | ||
%% If it is a LIST, use | ||
%% \item{comp1 }{Description of 'comp1'} | ||
%% \item{comp2 }{Description of 'comp2'} | ||
%% ... | ||
} | ||
\references{ | ||
%% ~put references to the literature/web site here ~ | ||
} | ||
\author{ | ||
%% ~~who you are~~ | ||
} | ||
\note{ | ||
%% ~~further notes~~ | ||
} | ||
|
||
%% ~Make other sections like Warning with \section{Warning }{....} ~ | ||
|
||
\seealso{ | ||
%% ~~objects to See Also as \code{\link{help}}, ~~~ | ||
} | ||
\examples{ | ||
##---- Should be DIRECTLY executable !! ---- | ||
##-- ==> Define data, use random, | ||
##-- or standard data sets, see data(). | ||
|
||
## The function is currently defined as | ||
function (Rinit, Iinit, Vinit, N, R0, a, eps, q) | ||
{ | ||
if (sum(Iinit) == 0) | ||
Iinit <- N/sum(N) | ||
Sinit <- N - Rinit - Iinit - Vinit | ||
fn <- (1 - eps) * a * N | ||
f <- fn/sum(fn) | ||
cij <- diag(eps) + outer((1 - eps), f) | ||
R0i <- R0/eigen(a * q * cij)$values[1] * a * q | ||
Zrhs <- function(Z) c(Sinit * (1 - exp(-R0i * cij \%*\% ((Z + | ||
Iinit)/N)))) | ||
optfn <- function(x) ifelse(all(x > 0), max(abs(x - Zrhs(x))), | ||
Inf) | ||
optVal <- Inf | ||
while (optVal > 1) { | ||
opt <- optim((0.01 + 0.98 * runif(length(N))) * N, optfn) | ||
optVal <- opt$value | ||
} | ||
opt$par + Iinit + Rinit | ||
} | ||
} | ||
% Add one or more standard keywords, see file 'KEYWORDS' in the | ||
% R documentation directory (show via RShowDoc("KEYWORDS")): | ||
% \keyword{ ~kwd1 } | ||
% \keyword{ ~kwd2 } | ||
% Use only one keyword per line. | ||
% For non-standard keywords, use \concept instead of \keyword: | ||
% \concept{ ~cpt1 } | ||
% \concept{ ~cpt2 } | ||
% Use only one concept per line. |
Oops, something went wrong.