Package 'nccovid'

Title: Pull North Carolina Covid-19 Outbreak Information
Description: This package allows users to easily retrieve data that have been pulled from the North Carolina Department of Health and Human Services Covid-19 Dashboard.
Authors: Michael DeWitt [aut, cre] , Jennifer Wenner [aut], Cone Health [aut, cph]
Maintainer: Michael DeWitt <[email protected]>
License: MIT + file LICENSE
Version: 0.0.21
Built: 2024-11-21 03:04:30 UTC
Source: https://github.com/conedatascience/nccovid

Help Index


Aerosol Concentration

Description

Estimate the aerosol concentration given environment parameters

Usage

aerosol_concentration(
  room_area = 60,
  room_height = 3,
  emission_breathing = 0.06,
  emission_speaking = 0.6,
  speaking_ratio = 0.1,
  resp_rate = 10
)

Arguments

room_area

a double, meters squared

room_height

a double, meters

emission_breathing

a double, emission while breathing cm^3

emission_speaking

a double, emission while speaking cm^3

speaking_ratio

a double, between 0 and 1 for ratio between speaking and breathing

resp_rate

a double, the respiratory rate in liters per minute


Aerosol Emission per Hour

Description

Estimate the aerosol emission rate per hours

Usage

aerosol_emission(
  emission_breathing = 0.06,
  emission_speaking = 0.6,
  speaking_ratio = 0.1,
  resp_rate = 10
)

Arguments

emission_breathing

a double, emission while breathing cm^3

emission_speaking

a double, emission while speaking cm^3

speaking_ratio

a double, between 0 and 1 for ratio between speaking and breathing

resp_rate

a double, the respiratory rate in liters per minute


Converts Infected persons, Number of Contact and Population to the associated probability of a contact

Description

Uses a Taylor approximation for repeated Binomial trials Classically associated with the "Birthday Problem"

Usage

calc_risk(I, n, pop)

Arguments

I

integer, the number of persons infected

n

integer, the number of contacts per day

pop

integer, the total population

Details

P(A) = 1- P(A)'


Calculating Community Immunity

Description

Considering Proportion of the Vaccinated and Those Who Were Infected

Usage

calculate_community_immunity(prop_infected, prop_vaccinated)

Arguments

prop_infected

a numeric representing the proportion of the population with natural infection

prop_vaccinated

a numeric representing the proportion of the population that is vaccinated.

Source

Lopman, B. A. et al. A framework for monitoring population immunity to SARS-CoV-2. Annals of Epidemiology S1047279721002635 (2021) doi:10.1016/j.annepidem.2021.08.013.

Examples

{

calculate_community_immunity(.3,.5)

plot(seq(.4,.7,.1),
calculate_community_immunity(prop_infected = seq(.4,.7,.1), 
		prop_vaccinated = .5), 
		ylab = "Community Immunity", 
		xlab = "Proportion Infected",
		main = "Community Immunity Given 50% Vaccinated", 
		adj =0)

}

Calculate Shannon Index for a Series

Description

Calculate Shannon Index for a Series

Usage

calculate_shannon(incidence)

Arguments

incidence

numeric, the case incidence

Value

double, the intensity of epidemic calculated via Shannon index

Examples

dat <- nccovid::get_covid_state(c("Guilford", "Forsyth", "Mecklenburg", "Wake"))

library(dplyr)
library(ggplot2)

counties <- unique(dat$county)
entropy_values = dat %>% 
	group_by(county) %>% 
	dplyr::group_split() %>% 
	lapply( function(x) calculate_shannon(incidence = x$cases_daily) ) %>%
	unlist()
	
entropy_values = data.frame(county = counties, intensity = entropy_values)
	entropy_values %>% 
	filter(county %in% nccovid::triad_counties) %>% 
	ggplot(aes(reorder(county,intensity), intensity))+
	geom_point()+
	coord_flip()+
	labs(
		title = "Epidemic Intensity"
	)

Transmission Increase

Description

Calculating the Transmission Increase from Factors

Usage

calculate_transmission_increase(R_w, rho, D = 4.7, omega = 0)

Arguments

R_w

a numeric, the baseline effective reproduction number

rho

a numeric, the estimated transmission advantage

D

a numeric, the generation time (average)

omega

a numeric with default of NULL indicating proportion of the population that has immunity against earlier variants

Examples

c(4,6) * calculate_transmission_increase(R_w = .8, .43, D = 5.2, omega = NULL)

c(4,6) * calculate_transmission_increase(R_w = .8, .43, D = 5.2, omega = .25)

Regions in Cone Region of Service

Description

Regions in Cone Region of Service

Usage

cone_region

Format

a vector


Mortality Estimates from Verity Et Al for Covid

Description

Mortality Estimates from Verity Et Al for Covid

Usage

covid_mortality_data

Format

data frame


Decrease Cases

Description

Decreased previous observed cases back to scale

Usage

decrease_cases(calculated_cases, pos_rate, m = 10.83, k = 0.5)

Arguments

calculated_cases

numeric, the calculated cases

pos_rate

numeric, the observed positivity rate

m

scaling factor

k

scaling factor with default of 1/2 on range [0,1]

Source

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4809590/


Vaccine Effectiveness

Description

Calculates Effective Vaccine Effectiveness as a function of parameters and time since vaccination. Includes heavyside function to accomendate the daily from injection

Usage

effective_ve_wane(VE = 0.8, omega = 0.1, t, theta = 0.3, t_2 = 14)

Arguments

VE

a numeric, the maximum vaccine efficacy

omega

a numeric, the rate parameter of wane

t

an integer, the day of interest

theta

a numeric, the general wane of the vaccine to be calibrated

t_2

an integer, the inflection of the heavyside

Examples

plot(0:30, effective_ve_wane(t = 0:30))

Convolution

Description

Perform a convolution given a pdf

Usage

epi_convolve(cases, pdf, direction = "forward")

Arguments

cases

numeric, the observed cases

pdf

numeric vector, the pdf of cases

direction

string, one of forward or backwards convolution

Examples

{
  
true_cases <- rpois(100, 5)
out <- data.frame(reported = ceiling(epi_convolve(true_cases, pdf = c(.2,.2,.3,.2,.1))),
true_cases,
date = 1:100
)

library(ggplot2)
ggplot(out, aes(date))+
	geom_line(aes(y = true_cases))+
	geom_line(aes(y = reported), color = "blue")
}

Final Size of An Epidemic

Description

Calculate the final size of an epidemic. Usethe the following logic:

Usage

epi_finalsize(r0)

Arguments

r0

a double, the reproduction number (can be basic or Reff)

Details

1 + 1/R0*W(-R0exp(-R0))

Examples

## Not run: 
epi_finalsize(3.5)

plot(seq(1,3,.01), epi_finalsize(seq(1,3,.01)),xlab = "R", 
ylab = "Percent Infected", type = "l")

## End(Not run)

Vaccine Coverage by Age

Description

Generates a graphic that shows the vaccine coverage by age band as a stacked bar chart in order to show the coverage as well as the raw number of vaccinated versus unvaccinated individuals.

Usage

generate_vax_coverage_age(county_use = nccovid::cone_region)

Arguments

county_use

a string vector representing the North Carolina counties to be displayed


Retrieve CDC COVID-19 Spread by County

Description

Utilizes the CDC's COVID-19 Tracker to General Information About the Spread of Disease.

Usage

get_cdc_detail()

Value

a data.table with details regarding disease spread by county

Source

<https://covid.cdc.gov/covid-data-tracker/#datatracker-home>


Retrieve CDC Vaccination Rates by County

Description

Utilizes the CDC's COVID-19 Tracker to Retrieve Vaccination Rates

Usage

get_cdc_vax()

Value

a data.table with vaccination information by county by day

Source

<https://covid.cdc.gov/covid-data-tracker/#datatracker-home>


Get Reported Demographics by County

Description

Retrieve Latest Demographic data from NC DHHS.

Usage

get_county_covid_demographics(
  demographic = "age_group",
  region = NULL,
  add_population = TRUE
)

Arguments

demographic

a string, one of age, k_12, ethnicity, gender, or race

region

a string vector, could a string or vector of the counties of interest

add_population

a boolean, TRUE to add the population estimates (may not be available for all demographics)

Examples

library(ggplot2)
library(data.table)
out <- get_county_covid_demographics(region = "Guilford", demographic = "age")

out[,per_capita:=cases/(population/100000)]
ggplot(out, aes(week_of, per_capita, colour = metric))+
geom_line()+
theme_bw()+
theme(legend.position = "top")+
labs(
title = "SARS-CoV-2 Cases per 100k Residents",
subtitle = "Guilford County, North Carolina",
x = "Cases per 100k",
y = NULL
)

Pull Testing Information at County Level

Description

Pulling information on tests and percent positive at the county level. Notes that these data are updated manually.

Usage

get_county_tests(county_select = NULL)

Arguments

county_select

a string, the county of counties of interest


Append Additional Information to COVID-19 Count Information

Description

Combined NCDHHS Case and Death Counts with CDC Details

Usage

get_covid_county_plus(county = NULL, adjusted = TRUE)

Arguments

county

a string vector, representing the counties of interest. If left NULL then all counties in North Carolina will be returned

adjusted

a logical, should the adjusted cases be used (to account for reporting gaps on weekends and holidays from NCDHHS). Defaults to TRUE

Value

a data.table with combined values for all counties or specified counties


Pull Covid-19 Demographics

Description

These data originate from the North Carolina DHHS Covid-19 Dashboard

Usage

get_covid_demographics()

Retrieve Covid19 Data

Description

This functions hits the Johns Hopkins Covid Data Repository and filters down to North Carolina Data. Alternatively, it can retrieve any state.

Usage

get_covid_state(
  state = "North Carolina",
  select_county = NULL,
  data_source = c("cone", "hopkins"),
  reporting_adj = FALSE
)

Arguments

state

with a default of North Carolina

select_county

the county, if desired

data_source

which data source you would like to use one of "cone" or "hopkins"

reporting_adj

a boolean, default of FALSE which adjust for two known issues with North Carolina Report occurring on 2020-09-25 when all antigen tests were added and on 2020-11-13 where only 10 hours of data were reported and the remaining cases were rolled into 2020-11-14. Also corrects for reporting lapses on Thanksgiving and Christmas Eve/ Christmas Day. On 2021-02-28 the dashboard was taken down for maintenance and thus unavailable on that day. Additionally note that on 2021-03-13 NCDHHS elected to not report data on Sundays. On 2021-03-19 NCDHHS notified users that on 2021-03-26 data would be updated Monday - Friday. Updated for Good Friday in which no results were posted.

Examples

## Not run: 
# To get all counties
get_covid_state()

# To get a single county
get_covid_state(select_county = "Guilford")

## End(Not run)

Pull Covid Data by Zip Code

Description

This function will pull down NC Covid Information by Zip Code

Usage

get_covid_zip()

Get Google Mobility Data

Description

This is a helper function to automatically access Google's Mobility data for North Carolina Counties

Usage

get_google_mobility(counties = NULL)

Arguments

counties

a string vector of the desired counties deafult of NULL returns all counties.

Source

<https://www.gstatic.com/covid19/mobility/Global_Mobility_Report.csv>

Examples

## Not run: 
# Return All NC Counties
get_google_mobility()

# Return a Specific County
get_google_mobility("Alamance County")


## End(Not run)

Get Google Mobility (Version 2) This is a helper function to automatically access Google's Mobility data for North Carolina Counties. It's a bit faster than 'get_google_mobility' which downloads the entire csv for the world

Description

Get Google Mobility (Version 2) This is a helper function to automatically access Google's Mobility data for North Carolina Counties. It's a bit faster than 'get_google_mobility' which downloads the entire csv for the world

Usage

get_google_mobility2(counties = NULL, state_in = "North Carolina")

Arguments

counties

a string vector of the desired counties default of NULL returns all counties.

state_in

a string vector representing state or states of interest


Get Reported Hospitalisation Data

Description

Retrieve Latest Hospitalisation data from NC DHHS. This is not an automatic Scrap so there could be some delay.

Usage

get_hospitalizations()

Pull Vaccination Rates by County

Description

Pulled from <conedatascience/covid-data>

Usage

get_vaccinations(county_list = NULL, add_population = TRUE)

Arguments

county_list

a string, the county to pull. default is all counties

add_population

a boolean, default of TRUE to add a population

Examples

{

get_vaccinations(county_list = "Guilford")

}

Pull Vaccinations by County and Demographic

Description

Pulled from <conedatascience/covid-data>. The column vax_n returns vaccination counts. Population references are available for the user to calculate distribution and/or per capita rates.

Usage

get_vaccinations_demo(county_list = NULL, demographic = NULL, status = NULL)

Arguments

county_list

a string, the county to pull. default is all counties.

demographic

a string, the demographic requested. one or more of "race", "age", "ethnicity", "sex". default is all demographics

status

string, either 'partial' or 'full' for number of people with partially or fully vaccinated. Default of NULL returns both.

Examples

{

get_vaccinations_demo(county_list = "Guilford",
                      demographic = 'race', status = 'partial')

}

Calculate Herd Immunity Threshold

Description

Calculates Basic Herd Immunity Threshold Based on the Basic Reproduction Number

Usage

hit(R0)

Arguments

R0

a positive double, the basic reproduction number

Examples

# Calculate the Herd Immunity Threshold for R0 Between 1 and 9
o <- vapply(seq(1,9, .1), hit, FUN.VALUE = numeric(1))

plot(seq(1,9, .1), o, main = "HIT", type = "l",
    ylab = "Prop with Immunity", xlab = expression(R[0]))

Increase Cases

Description

Increase case count in the presence of high testing positivity

Usage

increase_cases(observed_cases, pos_rate, m = 10.83, k = 0.5)

Arguments

observed_cases

numberic, the reported cases

pos_rate

numberic, the observed positivity rate

m

scaling factor

k

scaling factor with default of 1/2 on range [0,1]

Source

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4809590/


Infection Probability

Description

Calculate Infection probability given D50 1-10^(log10(.5)/D50)

Usage

infection_probability(D50 = 316)

Arguments

D50

a double, #RNA for 50 percent infection probability (D50)


Italy Estimates

Description

Italy Estimates

Usage

italy_rates

Format

a data.frame


Lambert W function

Description

Computes the Lambert W function, giving efficient solutions to the equation x*exp(x)==x lambertW(z, b = 0, maxiter = 10, eps = .Machine$double.eps, min.imag = 1e-09)

Usage

lambertW(z, b = 0, maxiter = 10, eps = .Machine$double.eps, min.imag = 1e-09)

Arguments

z

(complex) vector of values for which to compute the function

b

integer, defaults to 0. vector of branches: b=0 specifies the principal branch, 0 and -1 are the ones that can take non-complex values

maxiter

maximum numbers of iterations for convergence

eps

convergence tolerance

min.imag

maximum magnitude of imaginary part to chop when returning solutions

Details

Compute the Lambert W function of z. This function satisfies W(z)*exp(W(z)) = z, and can thus be used to express solutions of transcendental equations involving exponentials or logarithms. The Lambert W function is also available in Mathematica (as the ProductLog function), and in Maple and Wolfram.

Author(s)

Nici Schraudolph <schraudo at inf.ethz.ch> (original version (c) 1998), Ben Bolker (R translation) See <https://stat.ethz.ch/pipermail/r-help/2003-November/042793.html>

References

Corless, Gonnet, Hare, Jeffrey, and Knuth (1996), "On the Lambert W Function", Advances in Computational Mathematics 5(4):329-359


NC Biological Sex Information by County

Description

NC Biological Sex Information by County

Usage

nc_county_demos

Format

a data.frame, with NC DHHS county level demographic metrics

Source

American Community Survey (2020 Vintage)


NC Fips by County

Description

NC Fips by County

Usage

nc_county_fips

Format

a data.frame

Source

https://www.lib.ncsu.edu/gis/countyfips


NCDHHS Reported Delay Distribution

Description

Reported testing and reporting delays were fit using the EpiNow2 boostrapped gamma fit. The reported delays were manually collected from the NCDHHS website.

Usage

nc_delay

Format

a list, with parameters for a gamma distribution fit to delays

Source

https://covid19.ncdhhs.gov/dashboard/testing


Key North Carolina Events

Description

Key North Carolina Events

Usage

nc_events

Format

a data.frame

Source

various and https://www.nc.gov/covid-19/staying-ahead-curve


Mortality and Hospitalization Estimates

Description

Mortality and Hospitalization Estimates

Usage

nc_fatality_estimates

Format

data.frame


NC Hospital Preparedness Coalitions

Description

NC Hospital Preparedness Coalitions

Usage

nc_hc_coalitions

Format

a data.frame, with NC county name and associated coalition

Source

https://easternhpc.com/state-coalition-map/


North Carolina Population by County by Age

Description

North Carolina Population by County by Age

Usage

nc_pop_age

Format

a data.frame

Source

ACS2020 Metrics


NC Population by NCDHHS Age Band

Description

NC Population by NCDHHS Age Band

Usage

nc_pop_dhhs

Format

a data.frame

Source

2020 ACS Survey


North Carolina Population by County

Description

North Carolina Population by County

Usage

nc_population

Format

a data.frame

Source

Source: North Carolina OSBM, Standard Population Estimates, Vintage 2018 and Population Projections, Vintage 2019 <https://www.osbm.nc.gov/demog/county-estimates>


CDC Social Vulnerability for North Carolina by County

Description

CDC Social Vulnerability for North Carolina by County

Usage

nc_svi_county

Format

a data.frame

Source

[U.S. Centers for Disease Prevention and Control (CDC) Social Vulnerability Index (SVI)](https://svi.cdc.gov/)


Retrieve State Summary Metrics

Description

This pulls the most up to date summary data from the state.

Usage

pull_covid_summary()

Value

a data.table with information for North Carolina


Pull Latest Estimates

Description

All estimates for North Carolina and some select regions have been precalculated and available for download. These estimates are utilising the EpiNow2 package

Usage

pull_estimates(region = NULL, variable = "R")

Arguments

region

a string or string vector, the region or county of interest

variable

a string or string vector, the measure of interest


Pull Hospitalization Demographics

Description

A Helper Function That Pull Hospitalizations by Demographics as Posted by NCDHHS

Usage

pull_hospitalization_demos()

Value

a data.table

Examples

o <- pull_hospitalization_demos()

age_only <-o[demographic=="Age"&covid_status=="Confirmed"]

age_only <- age_only[date<Sys.Date()-90]

plot(NULL, 
	 xlim=range(age_only$date), 
	 ylim=range(age_only$value), ylab="Admissions", 
	 xlab="Date", main = "Admissions by Age")

buckets <- unique(age_only$category)

my_cols <- c("#00A2B2", "#F1BD51", "#00205C", "#c9c9c9", "#7750A9", "#B7D866", 
					 "#5C5859", "#DB2B27", "#63CCFF", "#000000", "#123453")
names(my_cols) <- buckets

for(i in buckets){
lines(age_only[category==i]$date,
			age_only[category==i]$value,
			col = my_cols[[i]])
}

Pull Vaccine Information by Census Tract

Description

The purpose of this function is to pull data provided by NCDHHS on vaccination rates by census tract. Additionally, information on SVI and other demographics is provided

Usage

pull_vaccine_census(county_pull = NULL)

Arguments

county_pull

a vector, the counties to select for the query

Value

a data.table with vaccination rates at the census tract level


Pull Wastewaster Treatment Data

Description

A helper function to pull SARS-CoV-2 Copies Detected in Wastewater

Usage

pull_wastewater(county_in = NULL)

Arguments

county_in

a string vector indicating the counties served with a default of NULL returning all counties

Examples

raw_dat <- pull_wastewater(county_in = "Guilford")
raw_dat <- raw_dat[!is.na(sars_cov2_raw_copiesL)][,copies_log10 := log10(sars_cov2_normalized)]

par(mar = c(5, 4, 4, 4) + 0.3)
plot(copies_log10~date_new, data = raw_dat, type ="b", 
    xlab = "Date", ylab = "SARS-CoV-2 RNA Copies (Log10)")
par(new = TRUE)
plot(log10(cases_new_cens_per10k)~date_new, data = raw_dat,
		 type = "l", axes = FALSE, bty = "n", xlab = "", ylab = "", col = "orange")
axis(side=4, at = pretty(range(log10(raw_dat$cases_new_cens_per10k))))
mtext("Log10(New Cases per 100k)", side=4, line=3)
title("Guilford SARS-CoV-2 Detected in Wastewater vs New Cases per 100k")

Convert Growth Rate to Reproduction Number

Description

Convenience function to convert a growth rate (little r) to a reproduction number (R) given a particular generation time.

Usage

r2R(r, mu_gamma = 4.7, sd_gamma = 2.9)

Arguments

r

a double representing the growth rate

mu_gamma

a double representing mean of the gamma function characterizing the generation time.

sd_gamma

a double representing standard deviation of the gamma function characterizing the generation time.

Source

https://royalsocietypublishing.org/doi/10.1098/rsif.2020.0144

Examples

cases <- rpois(10,2.5)
t <- 1:10
fit <- glm(cases ~ t, family = "poisson")

r2R(coef(fit)[2])

RNA Content in Aerosol

Description

Estimate the RNA Content in an Aerosol

Usage

rna_content(resp_fluid = 5e+08, wet_aerosol_diameter = 5)

Arguments

resp_fluid

a double, respiratory fluid RNA conc [/cm^3]

wet_aerosol_diameter

a double, mean wet aerosol diameter [um]


List of Triad Counties

Description

List of Triad Counties

Usage

triad_counties

Format

a vector