-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
1502467
commit 1c6a345
Showing
14 changed files
with
513 additions
and
417 deletions.
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 |
---|---|---|
@@ -1,70 +1,71 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
S3method("[",seroincidence.by) | ||
S3method(plot,seroincidence) | ||
S3method(plot,seroincidence.by) | ||
S3method(plot,summary.seroincidence.by) | ||
S3method(print,seroincidence) | ||
S3method(print,seroincidence.by) | ||
S3method(print,summary.seroincidence.by) | ||
S3method(strata,default) | ||
S3method(summary,seroincidence) | ||
S3method(summary,seroincidence.by) | ||
export(est.incidence) | ||
export(est.incidence.by) | ||
export(fdev) | ||
export(getAdditionalData) | ||
export(graph.loglik) | ||
export(sim.cs) | ||
export(sim.cs.multi) | ||
importFrom(Rcpp,sourceCpp) | ||
importFrom(doParallel,registerDoParallel) | ||
importFrom(dplyr,across) | ||
importFrom(dplyr,all_of) | ||
importFrom(dplyr,anti_join) | ||
importFrom(dplyr,any_of) | ||
importFrom(dplyr,bind_rows) | ||
importFrom(dplyr,count) | ||
importFrom(dplyr,distinct) | ||
importFrom(dplyr,everything) | ||
importFrom(dplyr,filter) | ||
importFrom(dplyr,inner_join) | ||
importFrom(dplyr,is.grouped_df) | ||
importFrom(dplyr,mutate) | ||
importFrom(dplyr,n) | ||
importFrom(dplyr,n_distinct) | ||
importFrom(dplyr,pull) | ||
importFrom(dplyr,relocate) | ||
importFrom(dplyr,rename) | ||
importFrom(dplyr,row_number) | ||
importFrom(dplyr,select) | ||
importFrom(dplyr,semi_join) | ||
importFrom(dplyr,tibble) | ||
importFrom(dplyr,ungroup) | ||
importFrom(foreach,"%:%") | ||
importFrom(foreach,"%dopar%") | ||
importFrom(foreach,foreach) | ||
importFrom(ggplot2,aes) | ||
importFrom(lifecycle,deprecated) | ||
importFrom(magrittr,"%>%") | ||
importFrom(rlang,.data) | ||
importFrom(rlang,.env) | ||
importFrom(rngtools,RNGseq) | ||
importFrom(rngtools,setRNG) | ||
importFrom(stats,dlnorm) | ||
importFrom(stats,formula) | ||
importFrom(stats,nlm) | ||
importFrom(stats,optim) | ||
importFrom(stats,pgamma) | ||
importFrom(stats,plnorm) | ||
importFrom(stats,qnorm) | ||
importFrom(stats,runif) | ||
importFrom(stats,xtabs) | ||
importFrom(tibble,as_tibble) | ||
importFrom(tibble,column_to_rownames) | ||
importFrom(tibble,tibble) | ||
importFrom(tidyr,drop_na) | ||
importFrom(tidyr,pivot_longer) | ||
importFrom(utils,download.file) | ||
importFrom(utils,unzip) | ||
useDynLib(serocalculator, .registration = TRUE) | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
S3method("[",seroincidence.by) | ||
S3method(plot,seroincidence) | ||
S3method(plot,seroincidence.by) | ||
S3method(plot,summary.seroincidence.by) | ||
S3method(print,seroincidence) | ||
S3method(print,seroincidence.by) | ||
S3method(print,summary.seroincidence.by) | ||
S3method(strata,seroincidence.by) | ||
S3method(summary,seroincidence) | ||
S3method(summary,seroincidence.by) | ||
export(est.incidence) | ||
export(est.incidence.by) | ||
export(fdev) | ||
export(getAdditionalData) | ||
export(graph.loglik) | ||
export(mkbaseline) | ||
export(sim.cs) | ||
export(sim.cs.multi) | ||
importFrom(Rcpp,sourceCpp) | ||
importFrom(doParallel,registerDoParallel) | ||
importFrom(dplyr,across) | ||
importFrom(dplyr,all_of) | ||
importFrom(dplyr,anti_join) | ||
importFrom(dplyr,any_of) | ||
importFrom(dplyr,bind_rows) | ||
importFrom(dplyr,count) | ||
importFrom(dplyr,distinct) | ||
importFrom(dplyr,everything) | ||
importFrom(dplyr,filter) | ||
importFrom(dplyr,inner_join) | ||
importFrom(dplyr,is.grouped_df) | ||
importFrom(dplyr,mutate) | ||
importFrom(dplyr,n) | ||
importFrom(dplyr,n_distinct) | ||
importFrom(dplyr,pull) | ||
importFrom(dplyr,relocate) | ||
importFrom(dplyr,rename) | ||
importFrom(dplyr,row_number) | ||
importFrom(dplyr,select) | ||
importFrom(dplyr,semi_join) | ||
importFrom(dplyr,tibble) | ||
importFrom(dplyr,ungroup) | ||
importFrom(foreach,"%:%") | ||
importFrom(foreach,"%dopar%") | ||
importFrom(foreach,foreach) | ||
importFrom(ggplot2,aes) | ||
importFrom(lifecycle,deprecated) | ||
importFrom(magrittr,"%>%") | ||
importFrom(rlang,.data) | ||
importFrom(rlang,.env) | ||
importFrom(rngtools,RNGseq) | ||
importFrom(rngtools,setRNG) | ||
importFrom(stats,dlnorm) | ||
importFrom(stats,formula) | ||
importFrom(stats,nlm) | ||
importFrom(stats,optim) | ||
importFrom(stats,pgamma) | ||
importFrom(stats,plnorm) | ||
importFrom(stats,qnorm) | ||
importFrom(stats,runif) | ||
importFrom(stats,xtabs) | ||
importFrom(tibble,as_tibble) | ||
importFrom(tibble,column_to_rownames) | ||
importFrom(tibble,tibble) | ||
importFrom(tidyr,drop_na) | ||
importFrom(tidyr,pivot_longer) | ||
importFrom(utils,download.file) | ||
importFrom(utils,unzip) | ||
useDynLib(serocalculator, .registration = TRUE) |
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,18 @@ | ||
# not used? | ||
ltpar <- function(k.test, ...) { | ||
y0.mc <- par.pred(1, k.test, ...) | ||
|
||
y1.mc <- par.pred(2, k.test, ...) | ||
|
||
t1.mc <- par.pred(3, k.test, ...) | ||
|
||
alpha.mc <- par.pred(4,k.test, ...); | ||
shape.mc <- par.pred(5,k.test, ...); | ||
return( | ||
data.frame( | ||
"y1"=y1.mc, | ||
"alpha"=alpha.mc, | ||
"r"=shape.mc, | ||
"y0"=y0.mc, | ||
"t1"=t1.mc)); | ||
} |
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,69 @@ | ||
|
||
### these below are copied from Pater's par-extract.r script | ||
par.pred <- function(parnum, k.test, predpar) | ||
{ | ||
if (parnum == 2) | ||
{ | ||
par1 <- exp(predpar[k.test, 1, ]) | ||
|
||
par2 <- exp(predpar[k.test, parnum, ]) | ||
|
||
return(par1 + par2) | ||
|
||
} else | ||
{ | ||
|
||
par <- exp(predpar[k.test, parnum, ]) | ||
|
||
if (parnum == 5) | ||
{ | ||
return(par + 1) | ||
} else | ||
{ | ||
return(par) | ||
} | ||
|
||
} | ||
} | ||
|
||
|
||
|
||
# Generate longitudinal parameter sample for the simulation model | ||
# parnum: use y0=par[1]; b0=par[2]; mu0=par[3]; mu1=par[4]; c1=par[5]; | ||
# alpha=par[6]; shape=par[7] (dmu = mu1 - mu0; b0 = 1) | ||
mu1fn <- function(y0,y1,t1) log(y1/y0)/t1; | ||
mu0fn <- function(beta,y0,y1,t1) mu1fn(y0,y1,t1)*exp(beta)/(1+exp(beta)); | ||
dmufn <- function(beta,y0,y1,t1) mu1fn(y0,y1,t1)/(1+exp(beta)); | ||
t1fn <- function(beta,y0,y1,t1,c1) | ||
log(1+dmufn(beta,y0,y1,t1)/(c1*y0))/dmufn(beta,y0,y1,t1); | ||
y1fn <- function(beta,y0,y1,t1,c1) | ||
y0*(1+dmufn(beta,y0,y1,t1)/(c1*y0))^(1+exp(beta)) | ||
objfnt1 <- function(par,y0,y1,t1) (t1-t1fn(par[1],y0,y1,t1,exp(par[2])))^2; | ||
# the longitudinal model estimates observables: y0, y1, t1, alpha, shape | ||
# for the simulation model we need mu0, mu1 and c1 (=c/b0) | ||
# mu1 can be calculated (see above) but mu0 and c1 are not so easy | ||
# the equation for t1 (above) can be used to calculate dmu (= mu1 - mu0) | ||
# and c1. We need a pair (dmu, c1) that minimizes the difference | ||
# (t1 - t1fn(dmu, c1, y0))^2. This is done in the following function | ||
estpart1 <- function(y0,y1,t1){ | ||
# est <- nlm(objfn,c(-1,-12),y0=y0,t1=t1); # print(est$estimate); | ||
# if(sqrt(est$minimum/t1)>1e0) print(sqrt(est$minimum));# return(NA); | ||
# return(exp(est$estimate)); | ||
est <- optim(c(-1,-12),objfnt1,y0=y0,y1=y1,t1=t1,method="Nelder-Mead"); | ||
if(sqrt(est$value/t1)>1e-1) print(sqrt(est$value)); | ||
return(c(exp(est$par[1])/(1+exp(est$par[1])),exp(est$par[2]))); | ||
} | ||
|
||
par.pred.n <- function(parnum,k.test,nmc, predpar, ...){ | ||
if(parnum==2){ | ||
par1 <- exp(predpar[k.test,1,nmc]); | ||
par2 <- exp(predpar[k.test,parnum,nmc]); | ||
return(par1+par2); | ||
} | ||
par <- exp(predpar[k.test,parnum,nmc]); | ||
if(parnum==5) return(par+1); # this step converts d to r | ||
return(par); | ||
} | ||
|
||
|
||
|
Oops, something went wrong.