C_worked_example01.RmdThis is an example of how to create a new dataset folder and populate it with equilibrium starting data for a range of baseline malaria level values. The R code used here can also be found in the create_dataset.R file in the vectorpower/inst/ folder.
First load the package (install it first if necessary as shown in the Installation article:
library(vectorpower)To create a new data set, it is necessary to specify the files to be used to load the parameter values governing the malaria model. Three files are used:
-param_file, which contains the main set of model parameters along with the parameters used to calculate rainfall as a function of time (which controls the seasonality of malaria) -age_file, which specifies the age intervals used for the human population -het_file, which specifies the parameter values controlling biting heterogeneity
In this example, the three parameter files are located in the vectorpower repository itself and their locations input using the system.file() commaand.
param_file=system.file("extdata/", "/param_examples/model_parameters_Mali.txt", package = 'vectorpower', mustWork = TRUE)
age_file=system.file("extdata/", "/param_examples/age_data_145.txt", package = 'vectorpower', mustWork = TRUE)
het_file=system.file("extdata/", "/param_examples/het_data_9.txt", package = 'vectorpower', mustWork = TRUE)To specify online file locations, use url() as shown:
param_file=url("https://raw.githubusercontent.com/KeithJF82/vectorpower/master/inst/extdata/param_examples/model_parameters_const.txt")
age_file=url("https://raw.githubusercontent.com/KeithJF82/vectorpower/master/inst/extdata/param_examples/age_data_145.txt")
het_file=url("https://raw.githubusercontent.com/KeithJF82/vectorpower/master/inst/extdata/param_examples/het_data_9.txt")To load from a location on the computer where vectorpower is being run, give the file names and location in the hierarchy of data folders as shown below:
input_folder="C:/Users/YourName/Documents/GitHub/vectorpower/inst/extdata/param_examples"
param_file=paste(input_folder,"model_parameters_Mali.txt",sep="/")
age_file=paste(input_folder,"age_data_145.txt",sep="/")
het_file=paste(input_folder,"het_data_9.txt",sep="/")The location of the folder where the new data set is to be created must also be specified. If a folder with the same already exists and contains an existing dataset, the dataset files in that folder will be overwritten. In this example, the output location is placed in the inst/extdata sub-folder in the vectorpower package folder (and will overwrite an existing, identical dataset).
output_location = system.file("extdata",package="vectorpower")
dataset_location = "DemoFolder1"
dataset_folder=paste(output_location,dataset_location,sep="/")To change the output, change output_location to another existing folder, e.g.:
output_location = "C:/Users/YourName/Documents/VPDatasets"
dataset_location = "Demo Folder 1"
dataset_folder=paste(output_location,dataset_location,sep="/")Ensure that folder names are separated by a “/”. Alternatively, substitute the entire folder name for dataset_folder, e.g.:
dataset_folder="C:/Users/YourName/Documents/VPDatasets/DemoFolder1"The baseline malaria levels represented by the input data to go in the dataset are set by specifying a vector of values of steady-state annual entomological inoculation rate (EIR). These values will not exactly match the year-round EIR values represented by the data once the time-dependent model has been run; the final dataset will include a file specifying the year-round EIR at equilibrium under the time-dependent model.
In this example, the EIR values are between 50 and 100 infectious bites per person per year:
EIR_values=c(50.0,60.0,70.0,80.0,90.0,100.0)Next, the integer number of years (from 1-20) for which the time-dependent model should be run to reach equilibrium must be specified. The more years for which it is run, the more stable the equilibrium; if the equilibrium is less stable, the malaria level will vary more significantly from year to year in calculations if the model is run for multiple years. For most purposes, running for at least 5 years is sufficient. In this example, nyears is set to 1 for speed.
nyears=10With all the parameters specified, the dataset_create function is run. This will first set initial conditions using steady-state calculations, then run the time-dependent model for the specified number of years to reach equilibrium. The results will be output as the dataset’s starting data. The year-round data output from the starting data (assuming no new interventions) will then be calculated and output as an aid to users of the dataset.
data1 <- create_data_folder(dataset_folder=dataset_folder,param_file=param_file,age_file=age_file,het_file=het_file,EIR_values=EIR_values,nyears=nyears)[Code block above is not currently evaluated.]