Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sirplus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioCellGen-public
sirplus
Commits
ceaa6b8a
Commit
ceaa6b8a
authored
4 years ago
by
pqiao29
Browse files
Options
Downloads
Patches
Plain Diff
confirm all changed functions return identical values as the originals
parent
78e69880
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
R/FUN_arrivals.R
+0
-5
0 additions, 5 deletions
R/FUN_arrivals.R
R/icm_seiqhrf.R
+14
-13
14 additions, 13 deletions
R/icm_seiqhrf.R
R/internal_update.R
+0
-0
0 additions, 0 deletions
R/internal_update.R
tests/testthat/test-icm-seiqhrf.R
+29
-0
29 additions, 0 deletions
tests/testthat/test-icm-seiqhrf.R
with
43 additions
and
18 deletions
R/FUN_arrivals.R
+
0
−
5
View file @
ceaa6b8a
...
...
@@ -28,11 +28,6 @@ arrivals.FUN <- function(dat, at, seed = NULL) {
nOld
<-
dat
$
epi
$
num
[
at
-
1
]
type
<-
dat
$
control
$
type
nsteps
<-
dat
$
control
$
nsteps
a.rate.g2
<-
dat
$
param
$
a.rate.g2
a.prop.e.g2
<-
dat
$
param
$
a.prop.e.g2
a.prop.i.g2
<-
dat
$
param
$
a.prop.i.g2
a.prop.q.g2
<-
dat
$
param
$
a.prop.q.g2
# Process: partition arrivals into compartments -----------------------------------------------------------------
nArrivals
<-
ifelse
(
a.rand
,
sum
(
stats
::
rbinom
(
nOld
,
1
,
a.rate
)),
round
(
nOld
*
a.rate
))
...
...
This diff is collapsed.
Click to expand it.
R/icm_seiqhrf.R
+
14
−
13
View file @
ceaa6b8a
...
...
@@ -68,7 +68,8 @@ merge.seiqhrf.icm <- function(x, y, ...) {
#' @importFrom EpiModel verbose.icm
#' @importFrom future availableCores
#' @export
icm.seiqhrf
<-
function
(
param
,
init
,
control
)
{
icm.seiqhrf
<-
function
(
param
,
init
,
control
,
seed
=
NULL
)
{
crosscheck.seiqhrf.icm
(
param
,
init
,
control
)
EpiModel
::
verbose.icm
(
control
,
type
=
"startup"
)
...
...
@@ -83,7 +84,7 @@ icm.seiqhrf <- function(param, init, control) {
## Initialization module
if
(
!
is.null
(
control
[[
"initialize.FUN"
]]))
{
dat
<-
do.call
(
control
[[
"initialize.FUN"
]],
list
(
param
,
init
,
control
))
dat
<-
do.call
(
control
[[
"initialize.FUN"
]],
list
(
param
,
init
,
control
,
seed
))
}
...
...
@@ -94,31 +95,31 @@ icm.seiqhrf <- function(param, init, control) {
um
<-
control
$
user.mods
if
(
length
(
um
)
>
0
)
{
for
(
i
in
1
:
length
(
um
))
{
dat
<-
do.call
(
control
[[
um
[
i
]]],
list
(
dat
,
at
))
dat
<-
do.call
(
control
[[
um
[
i
]]],
list
(
dat
,
at
,
seed
))
}
}
## Infection
if
(
!
is.null
(
control
[[
"infection.FUN"
]]))
{
dat
<-
do.call
(
control
[[
"infection.FUN"
]],
list
(
dat
,
at
))
dat
<-
do.call
(
control
[[
"infection.FUN"
]],
list
(
dat
,
at
,
seed
))
}
## Recovery
if
(
!
is.null
(
control
[[
"recovery.FUN"
]]))
{
dat
<-
do.call
(
control
[[
"recovery.FUN"
]],
list
(
dat
,
at
))
dat
<-
do.call
(
control
[[
"recovery.FUN"
]],
list
(
dat
,
at
,
seed
))
}
## Departure Module
if
(
!
is.null
(
control
[[
"departures.FUN"
]]))
{
dat
<-
do.call
(
control
[[
"departures.FUN"
]],
list
(
dat
,
at
))
dat
<-
do.call
(
control
[[
"departures.FUN"
]],
list
(
dat
,
at
,
seed
))
}
## Arrival Module
if
(
!
is.null
(
control
[[
"arrivals.FUN"
]]))
{
dat
<-
do.call
(
control
[[
"arrivals.FUN"
]],
list
(
dat
,
at
))
dat
<-
do.call
(
control
[[
"arrivals.FUN"
]],
list
(
dat
,
at
,
seed
))
}
...
...
@@ -155,7 +156,7 @@ icm.seiqhrf <- function(param, init, control) {
## Initialization module
if
(
!
is.null
(
control
[[
"initialize.FUN"
]]))
{
dat
<-
do.call
(
control
[[
"initialize.FUN"
]],
list
(
param
,
init
,
control
))
dat
<-
do.call
(
control
[[
"initialize.FUN"
]],
list
(
param
,
init
,
control
,
seed
))
}
# Timestep loop
...
...
@@ -165,31 +166,31 @@ icm.seiqhrf <- function(param, init, control) {
um
<-
control
$
user.mods
if
(
length
(
um
)
>
0
)
{
for
(
i
in
1
:
length
(
um
))
{
dat
<-
do.call
(
control
[[
um
[
i
]]],
list
(
dat
,
at
))
dat
<-
do.call
(
control
[[
um
[
i
]]],
list
(
dat
,
at
,
seed
))
}
}
## Infection
if
(
!
is.null
(
control
[[
"infection.FUN"
]]))
{
dat
<-
do.call
(
control
[[
"infection.FUN"
]],
list
(
dat
,
at
))
dat
<-
do.call
(
control
[[
"infection.FUN"
]],
list
(
dat
,
at
,
seed
))
}
## Recovery
if
(
!
is.null
(
control
[[
"recovery.FUN"
]]))
{
dat
<-
do.call
(
control
[[
"recovery.FUN"
]],
list
(
dat
,
at
))
dat
<-
do.call
(
control
[[
"recovery.FUN"
]],
list
(
dat
,
at
,
seed
))
}
## Departure Module
if
(
!
is.null
(
control
[[
"departures.FUN"
]]))
{
dat
<-
do.call
(
control
[[
"departures.FUN"
]],
list
(
dat
,
at
))
dat
<-
do.call
(
control
[[
"departures.FUN"
]],
list
(
dat
,
at
,
seed
))
}
## Arrival Module
if
(
!
is.null
(
control
[[
"arrivals.FUN"
]]))
{
dat
<-
do.call
(
control
[[
"arrivals.FUN"
]],
list
(
dat
,
at
))
dat
<-
do.call
(
control
[[
"arrivals.FUN"
]],
list
(
dat
,
at
,
seed
))
}
...
...
This diff is collapsed.
Click to expand it.
R/internal_update
_status
.R
→
R/internal_update.R
+
0
−
0
View file @
ceaa6b8a
File moved
This diff is collapsed.
Click to expand it.
tests/testthat/test-icm-seiqhrf.R
0 → 100644
+
29
−
0
View file @
ceaa6b8a
test_that
(
"Identical output as Churches' original function: icm_seiqhrf"
,
{
full_params
<-
set_param
(
s.num
=
1000
,
nsteps
=
10
)
param
<-
full_params
$
param
init
<-
full_params
$
init
#### default functions: initialize.FUN, infection.FUN, recovery.FUN, departures.FUN, arrivals.FUN
control1
<-
full_params
$
control
### Churches' original function:
control2
<-
control1
control2
$
initialize.FUN
<-
"initialize.icm"
control2
$
infection.FUN
<-
"infection.seiqhrf.icm"
control2
$
recovery.FUN
<-
"progress.seiqhrf.icm"
control2
$
departures.FUN
<-
"departures.seiqhrf.icm"
control2
$
arrivals.FUN
<-
"arrivals.seiqhrf.icm"
No_seeds
<-
10
seed_list
<-
sample
(
1
:
1000
,
No_seeds
)
comp
<-
rep
(
NA
,
No_seeds
)
i
<-
1
for
(
seed
in
seed_list
){
sim1
<-
icm.seiqhrf
(
param
,
init
,
control1
,
seed
)
sim2
<-
icm.seiqhrf
(
param
,
init
,
control2
,
seed
)
comp
[
i
]
<-
identical
(
sim1
,
sim2
)
i
<-
i
+
1
}
expect_equal
(
sum
(
comp
),
No_seeds
)
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment