-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Housing #267
Open
EllieSherrardSmith
wants to merge
12
commits into
dev
Choose a base branch
from
housing
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Housing #267
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
708c171
introducing capacity to simulate housing improvement by some impact t…
c64ea19
how to introduced housing changes
2c75d75
to update shortly
deb288c
DOCUMENTATION updated
58a3bff
correcting to matrix for phi housing
9447b24
do not think i need phi housing here
09924b2
working version but cleaner to change function in vector control R to…
b57935d
trying a false function to maintain rn_house high
e87f567
trying again this time without species
06152ce
trying
15409b3
Coding in capacity to adapt housing to increase barrier to mosquitoes…
b74a71f
Update vector_control.R
EllieSherrardSmith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -11,7 +11,7 @@ prob_bitten <- function( | |||||
parameters | ||||||
) { | ||||||
n <- parameters$human_population | ||||||
if (!(parameters$bednets || parameters$spraying)) { | ||||||
if (!(parameters$bednets || parameters$spraying || parameters$housing)) { | ||||||
return( | ||||||
list( | ||||||
prob_bitten_survives = rep(1, n), | ||||||
|
@@ -65,37 +65,84 @@ prob_bitten <- function( | |||||
js_prime, | ||||||
parameters$k0 | ||||||
) | ||||||
spray_on = 1 | ||||||
rs_comp <- 1 - rs | ||||||
ss <- rep(1, n) | ||||||
ss[protected_index] <- prob_survives_spraying( | ||||||
ks_prime, | ||||||
parameters$k0 | ||||||
) | ||||||
} else { | ||||||
phi_indoors <- 0 | ||||||
spray_on = 0 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
rs <- 0 | ||||||
rs_comp <- 1 | ||||||
ss <- 1 | ||||||
} | ||||||
|
||||||
if (parameters$housing) { | ||||||
phi_housing <- parameters$phi_housing[[species]] ## if a change in behaviour is caused by the housing changes, we can increase outdoor biting proportion | ||||||
phi_indoors <- parameters$phi_indoors[[species]] | ||||||
house_time <- variables$house_time$get_values() | ||||||
since_housing <- timestep - house_time | ||||||
matches <- match(house_time, parameters$housing_timesteps) | ||||||
rh <- prob_repelled_house(matches, since_housing, species, parameters) ## if housing prevents entry to house, we increase proportion needing to repeat foraging | ||||||
sh <- prob_survives_house(rh, matches, since_housing, species, parameters) | ||||||
unused <- house_time == -1 | ||||||
sh[unused] <- 1 | ||||||
rh[unused] <- 0 | ||||||
} else { | ||||||
phi_housing <- 1 | ||||||
rh <- 0 | ||||||
sh <- 1 | ||||||
} | ||||||
|
||||||
if ((!parameters$housing & !parameters$spraying)) { | ||||||
phi_indoors <- 0 ## we want phi_indoors to be applied if housing is on | ||||||
} | ||||||
|
||||||
list( | ||||||
prob_bitten_survives = ( | ||||||
1 - phi_indoors + | ||||||
phi_bednets * rs_comp * sn * ss + | ||||||
(phi_indoors - phi_bednets) * rs_comp * ss | ||||||
1 - phi_indoors * phi_housing + ## | ||||||
(1 - rh) * (phi_bednets * phi_housing * rs_comp * sn * ss * sh^2) + ## * sh if some mortality from housing | ||||||
(1 - rh) * ((phi_indoors * phi_housing - phi_bednets * phi_housing) * rs_comp * ss * sh^2) ## * sh if some mortality from housing | ||||||
), | ||||||
prob_bitten = ( | ||||||
1 - phi_indoors + | ||||||
phi_bednets * rs_comp * sn + | ||||||
(phi_indoors - phi_bednets) * rs_comp | ||||||
1 - phi_indoors * phi_housing + | ||||||
(1 - rh) * (phi_bednets * phi_housing * rs_comp * sn * sh) + ## * sh if some mortality from housing | ||||||
(1 - rh) * ((phi_indoors * phi_housing - phi_bednets * phi_housing) * rs_comp * sh) ## * sh if some mortality from housing | ||||||
), | ||||||
prob_repelled = ( | ||||||
phi_bednets * rs_comp * rn + | ||||||
phi_indoors * rs | ||||||
phi_bednets * phi_housing * rs_comp * sh * rn + | ||||||
phi_indoors * phi_housing * rs * sh * spray_on + | ||||||
phi_indoors * phi_housing * rh | ||||||
) | ||||||
) | ||||||
} | ||||||
|
||||||
#' @title Simulate housing improvements | ||||||
#' @description simulates improved housing so that harder for vectors to get indoors | ||||||
#' from `set_housing` and correlation parameters from | ||||||
#' `get_correlation_parameters` | ||||||
#' | ||||||
#' @param variables list of variables in the model | ||||||
#' @param parameters the model parameters | ||||||
#' @param correlations correlation parameters | ||||||
#' @noRd | ||||||
housing_improvement <- function(variables, parameters, correlations) { | ||||||
function(timestep) { | ||||||
matches <- timestep == parameters$housing_timesteps | ||||||
if (any(matches)) { | ||||||
target <- which(sample_intervention( | ||||||
seq(parameters$human_population), | ||||||
'housing', | ||||||
parameters$housing_coverages[matches], | ||||||
correlations | ||||||
)) | ||||||
variables$house_time$queue_update(timestep, target) | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
#' @title Indoor spraying | ||||||
#' @description models indoor residual spraying according to the strategy | ||||||
#' from `set_spraying` and correlation parameters from | ||||||
|
@@ -106,7 +153,7 @@ prob_bitten <- function( | |||||
#' @param correlations correlation parameters | ||||||
#' @noRd | ||||||
indoor_spraying <- function(spray_time, parameters, correlations) { | ||||||
function(timestep) { | ||||||
function(timestep) { | ||||||
matches <- timestep == parameters$spraying_timesteps | ||||||
if (any(matches)) { | ||||||
target <- which(sample_intervention( | ||||||
|
@@ -187,6 +234,22 @@ spraying_decay <- function(t, theta, gamma) { | |||||
1 / (1 + exp(-(theta + gamma * t))) | ||||||
} | ||||||
|
||||||
house_decay <- function(t, gamma) { | ||||||
exp(-t / gamma) | ||||||
} | ||||||
|
||||||
prob_repelled_house <- function(matches, dt, species, parameters) { | ||||||
rhm <- parameters$house_rhm[matches, species] | ||||||
gammah <- parameters$house_gammah[matches] | ||||||
(parameters$house_rh[matches, species] - rhm) * house_decay(dt, gammah) + rhm | ||||||
} | ||||||
|
||||||
prob_survives_house <- function(rh, matches, dt, species, parameters) { | ||||||
dh0 <- parameters$house_dh0[matches, species] | ||||||
dh <- dh0 * house_decay(dt, parameters$house_gammah[matches]) | ||||||
1 - rh - dh | ||||||
} | ||||||
|
||||||
net_usage_renderer <- function(net_time, renderer) { | ||||||
function(t) { | ||||||
renderer$render( | ||||||
|
@@ -196,3 +259,13 @@ net_usage_renderer <- function(net_time, renderer) { | |||||
) | ||||||
} | ||||||
} | ||||||
|
||||||
house_usage_renderer <- function(house_time, renderer) { | ||||||
function(t) { | ||||||
renderer$render( | ||||||
'n_use_house_adaptation', | ||||||
house_time$get_index_of(-1)$not(TRUE)$size(), | ||||||
t | ||||||
) | ||||||
} | ||||||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.