get.mysql: Retrieve incidence and climate data from MySQL database.

Description Usage Arguments Value Examples

View source: R/data_fxns.R

Description

This function is generally called by get.DICE.data. After retrieving the data is is formatted for use by DICE

Usage

1
2
3
4
5
get.mysql(mod_level = 2, fit_level = 3, mod_name = c(NAME_2 = "BR"),
  fit_names = "all", start.date = as.Date("2010-01-01"),
  end.date = as.Date("2010-12-31"), disease = "dengue",
  sql_data_source = NULL, season = NULL, all_years_flag = T,
  db_opts = list(DICE_db = "predsci", CDC_server = F), cad_clim = TRUE)

Arguments

mod_level

An integer describing the spatial level of the model data.(Default value is 2) Levels: 0-Global, 1-Continent, 2-Country, 3-Region, 4-State, 5-County, 6-City. dice currently has mydata at levels 2-3 for CDC and 2-4 for GFT.

fit_level

An integer describing the spatial level of the fits used to construct the model-level profile/forecast (Default value is 3, must be >= mod_level).

mod_name

A named-vector of character strings that specify which region is to be modeled. In other words, mod_name specifies the country, region, state, etc. of the mod_level region. mod_name should be of the form mod_name = c(NAME_2='a', NAME_3='b',..., NAME_i='x' where i=mod_level and 'a', 'b',...,'x' are the appropriate level names. NAME_i='x' also accepts abbreviations. Choose appropriate names from diceData. For example, mod_name=c(NAME_2='United.States',NAME_3='Region4',NAME_4='North.Carolina') and mod_level=4 specifies North Carolina. To achieve the same result, use all abbreviations mod_name=c(NAME_2='US',NAME_3='R4',NAME_4='NC') or a mix of names and abbreviations mod_name=c(NAME_2='US',NAME_3='Region4',NAME_4='NC'). Unlike get.cdc.data(), get.mysql() expects ISO2 country abbreviations.

start.date

A Date-class variable - start date of fitting period. Passing a NULL value causes the earliest available mydata to be returned.

end.date

A Date-class variable - end date of forecasting period. Passing a NULL value causes the latest available mydata to be returned.

disease

String - disease name. Options for modeling are: flu, dengue, yellow$\_$fever, ebola, zika, cholera, chik, plague. To graphically explore the data see: predsci.com/id$\_$data/. A full list of diseases in the DICE database can be found from an R-prompt by following one of the examples below.

sql_data_source

Describes the data source for the incidence data. Default is 'cdc' (for disease = 'flu'). It can be selected by source_key (integer) or source abbreviation (string). Most disease/location combinations have only one data source. In this case, it may be easier to set data_source=NULL. However, when multiple data sources exist, setting data_source=NULL will essentially choose from the available sources at random. To determine a data source by graphical interface, see: predsci.com/id_data/. Looking-up the disease and location will result in a list of data sources that can be entered into DICE. Alternatively, all country/disease/data_source combinations are listed in the ‘Data Sources Table’ tab at the same url. To access the list of sources directly from an R-prompt, see the examples below.

season

An integer (year) specifying the season. When only one year is needed and/or start/end dates are not certain, season can be set. If !is.null(season), it overrides the start./end.date inputs.

all_years_flag

Logic flag indicating if all years of incidence should be returned in addition to the specified season/date-range.

fit_name

A character vector indicating which fit-regions to use. If fit_name='all', then DICE uses all child-regions of the model region with level equal to fit_level. The other mode for fit_name is to specifiy a subset of the fit regions to construct an aggregate representation of the model region. For example if mod_level=c(NAME_2="US"), mod_level=2, fit_level=3, and fit_names=c("R1", "R2", "R3"), DICE will create an Atlantic super-region to model (as opposed to using all 10 HHS regions). Similarly, if mod_level=c(NAME_2="US"), mod_level=2, fit_level=4, and fit_names=c("WA", "OR", "CA"), DICE will create and model a super-state of Pacific states.

Value

mydata A list ILI, SH, School, and Census mydata for both the model- and fit-level region(s).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
require(DICE)
mydata = get.mysql(mod_level = 2, fit_level = 4, mod_name = c(NAME_2='BR'), start.date=as.Date("2010-01-01"), end.date=as.Date("2010-12-31"), disease="dengue", sql_data_source=1)

-- Data diseases and data_sources -------
Access the database and list all available diseases:
library(DICE)
myDB = OpenCon()
data_sources = dbReadTable(con=myDB, name="data_sources")
unique(data_sources$disease)
# then list all data sources
str(data_sources)
data_sources$source_abbv
dbDisconnect(myDB)

predsci/DICE documentation built on Aug. 9, 2019, 9:41 a.m.