Impact of Weather Events on U.S. Public Health and Economy

by Sandy Sng
9 May 2018

Synopsis

Storms and other severe weather events can cause both public health and economic problems for communities and municipalities. Many severe events can result in fatalities, injuries, and property damage, and preventing such outcomes to the extent possible is a key concern. This project involves exploring the U.S. National Oceanic and Atmospheric Administration’s (NOAA) storm database. This database tracks characteristics of major storms and weather events in the United States, including when and where they occur, as well as estimates of any fatalities, injuries, and property damage.

Data

The data for this assignment come in the form of a comma-separated-value file compressed via the bzip2 algorithm to reduce its size. You can download the file from the course web site:

- Storm Data

There is also some documentation of the database available. Here you will find how some of the variables are constructed/defined.

- National Weather Service Storm Data Documentation

- National Climatic Data Center Storm Events FAQ

The events in the database start in the year 1950 and end in November 2011. In the earlier years of the database there are generally fewer events recorded, most likely due to a lack of good records. More recent years should be considered more complete.

Goal of Analysis

The basic goal is to explore the NOAA Storm Database and answer some basic questions about severe weather events:

1) Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health?

2) Across the United States, which types of events have the greatest economic consequences?

Data Processing

Download file from url, unzip and read file:

setwd("~/Desktop/R Files")

library(R.utils) # For bunzip2
## Loading required package: R.oo
## Loading required package: R.methodsS3
## R.methodsS3 v1.7.1 (2016-02-15) successfully loaded. See ?R.methodsS3 for help.
## R.oo v1.22.0 (2018-04-21) successfully loaded. See ?R.oo for help.
## 
## Attaching package: 'R.oo'
## The following objects are masked from 'package:methods':
## 
##     getClasses, getMethods
## The following objects are masked from 'package:base':
## 
##     attach, detach, gc, load, save
## R.utils v2.6.0 (2017-11-04) successfully loaded. See ?R.utils for help.
## 
## Attaching package: 'R.utils'
## The following object is masked from 'package:utils':
## 
##     timestamp
## The following objects are masked from 'package:base':
## 
##     cat, commandArgs, getOption, inherits, isOpen, parse, warnings
if (!"stormData.csv.bz2" %in% dir("~/Desktop/R Files")) {
    download.file("http://d396qusza40orc.cloudfront.net/repdata%2Fdata%2FStormData.csv.bz2", destfile = "stormData.csv.bz2")
    bunzip2("data/stormData.csv.bz2", overwrite=T, remove=F)
}

if (!"stormData" %in% ls()) {
stormData <- read.csv("stormData.csv", header = TRUE)
}

Explore dataframe:

str(stormData)
## 'data.frame':    902297 obs. of  37 variables:
##  $ STATE__   : num  1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_DATE  : Factor w/ 16335 levels "1/1/1966 0:00:00",..: 6523 6523 4242 11116 2224 2224 2260 383 3980 3980 ...
##  $ BGN_TIME  : Factor w/ 3608 levels "00:00:00 AM",..: 272 287 2705 1683 2584 3186 242 1683 3186 3186 ...
##  $ TIME_ZONE : Factor w/ 22 levels "ADT","AKS","AST",..: 7 7 7 7 7 7 7 7 7 7 ...
##  $ COUNTY    : num  97 3 57 89 43 77 9 123 125 57 ...
##  $ COUNTYNAME: Factor w/ 29601 levels "","5NM E OF MACKINAC BRIDGE TO PRESQUE ISLE LT MI",..: 13513 1873 4598 10592 4372 10094 1973 23873 24418 4598 ...
##  $ STATE     : Factor w/ 72 levels "AK","AL","AM",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ EVTYPE    : Factor w/ 985 levels "   HIGH SURF ADVISORY",..: 834 834 834 834 834 834 834 834 834 834 ...
##  $ BGN_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ BGN_AZI   : Factor w/ 35 levels "","  N"," NW",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ BGN_LOCATI: Factor w/ 54429 levels ""," Christiansburg",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_DATE  : Factor w/ 6663 levels "","1/1/1993 0:00:00",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_TIME  : Factor w/ 3647 levels ""," 0900CST",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ COUNTY_END: num  0 0 0 0 0 0 0 0 0 0 ...
##  $ COUNTYENDN: logi  NA NA NA NA NA NA ...
##  $ END_RANGE : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ END_AZI   : Factor w/ 24 levels "","E","ENE","ESE",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ END_LOCATI: Factor w/ 34506 levels ""," CANTON"," TULIA",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ LENGTH    : num  14 2 0.1 0 0 1.5 1.5 0 3.3 2.3 ...
##  $ WIDTH     : num  100 150 123 100 150 177 33 33 100 100 ...
##  $ F         : int  3 2 2 2 2 2 2 1 3 3 ...
##  $ MAG       : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ FATALITIES: num  0 0 0 0 0 0 0 0 1 0 ...
##  $ INJURIES  : num  15 0 2 2 2 6 1 0 14 0 ...
##  $ PROPDMG   : num  25 2.5 25 2.5 2.5 2.5 2.5 2.5 25 25 ...
##  $ PROPDMGEXP: Factor w/ 19 levels "","-","?","+",..: 17 17 17 17 17 17 17 17 17 17 ...
##  $ CROPDMG   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ CROPDMGEXP: Factor w/ 9 levels "","?","0","2",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ WFO       : Factor w/ 542 levels ""," CI","%SD",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ STATEOFFIC: Factor w/ 250 levels "","ALABAMA, Central",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ ZONENAMES : Factor w/ 25112 levels "","                                                                                                               "| __truncated__,..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ LATITUDE  : num  3040 3042 3340 3458 3412 ...
##  $ LONGITUDE : num  8812 8755 8742 8626 8642 ...
##  $ LATITUDE_E: num  3051 0 0 0 0 ...
##  $ LONGITUDE_: num  8806 0 0 0 0 ...
##  $ REMARKS   : Factor w/ 436781 levels "","\t","\t\t",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ REFNUM    : num  1 2 3 4 5 6 7 8 9 10 ...
# Remove unnecessary columns
good_columns <- c("EVTYPE",                  # Event Type
                  "FATALITIES", "INJURIES",  # Fatalities & Injuries
                  "PROPDMG", "PROPDMGEXP",   # Property Damage & its exponential
                  "CROPDMG", "CROPDMGEXP")   # Crop Damage & its exponential
stormData <- stormData[,good_columns]
str(stormData)
## 'data.frame':    902297 obs. of  7 variables:
##  $ EVTYPE    : Factor w/ 985 levels "   HIGH SURF ADVISORY",..: 834 834 834 834 834 834 834 834 834 834 ...
##  $ FATALITIES: num  0 0 0 0 0 0 0 0 1 0 ...
##  $ INJURIES  : num  15 0 2 2 2 6 1 0 14 0 ...
##  $ PROPDMG   : num  25 2.5 25 2.5 2.5 2.5 2.5 2.5 25 25 ...
##  $ PROPDMGEXP: Factor w/ 19 levels "","-","?","+",..: 17 17 17 17 17 17 17 17 17 17 ...
##  $ CROPDMG   : num  0 0 0 0 0 0 0 0 0 0 ...
##  $ CROPDMGEXP: Factor w/ 9 levels "","?","0","2",..: 1 1 1 1 1 1 1 1 1 1 ...

1) Across the United States, which types of events (as indicated in the EVTYPE variable) are most harmful with respect to population health?

Top 3 events causing fatalities:

impactFatalities <- sort(
  tapply(stormData$FATALITIES, stormData$EVTYPE, sum),
  decreasing = T)

max(impactFatalities)
## [1] 5633

Top 3 events causing injuries:

impactInjuries <- sort(
  tapply(stormData$INJURIES, stormData$EVTYPE, sum),
  decreasing = T)

max(impactInjuries)
## [1] 91346

Top 3 events causing fatalities and injuries collectively:

stormData$HEALTH = stormData$FATALITIES + stormData$INJURIES

impactTotal <- sort(
  tapply(stormData$HEALTH, stormData$EVTYPE, sum),
  decreasing = T)

max(impactTotal)
## [1] 96979
# PlotA: Made up of 3 plots (create 1x3, arrange row-wise)
# Plot1: Top 3 events causing fatalities
# Plot2: Top 3 events causing injuries
# Plot3: Top 3 events causing fatalities and injuries collectively:

par(mfrow=c(1,3), mar=c(4,4,2,1), oma=c(0,0,2,0))
with(stormData, {
        # Plot1
        barplot(head(impactFatalities,3),
        main = "Top 3 Most Harmful Events causing Fatalities",
        xlab = "Event Type",
        ylab = "Total Fatalities")  
        
        # Plot2
        barplot(head(impactInjuries,3),
        main = "Top 3 Most Harmful Events causing Injuries",
        xlab = "Event Type",
        ylab = "Total Injuries")
        
        # Plot3
        barplot(head(impactTotal,3),
        main = "Top 3 Most Harmful Events causing Fatalities and Injuries",
        xlab = "Event Type",
        ylab = "Total Fatalities and Injuries")
}
)

dev.copy(png,'plotA.png')
## quartz_off_screen 
##                 3
dev.off()
## quartz_off_screen 
##                 2

The most harmful events with respect to population health (right-most graph) are TORNADO, EXCESSIVE HEAT, and TSTM WIND.

2) Across the United States, which types of events have the greatest economic consequences? Convert the property damage and crop damage data into comparable numerical forms according to the meaning of units described in the code book (Storm Events). Both PROPDMGEXP and CROPDMGEXP columns record a multiplier for each observation where we have Hundred (H), Thousand (K), Million (M) and Billion (B).

tidystormData <- stormData[,c('EVTYPE','FATALITIES','INJURIES', 'PROPDMG', 'PROPDMGEXP', 'CROPDMG', 'CROPDMGEXP')]

# Convert H, K, M, B units to calculate Property Damage 
tidystormData$PROPDMGNUM = 0

tidystormData[tidystormData$PROPDMGEXP == "H", ]$PROPDMGNUM = tidystormData[tidystormData$PROPDMGEXP == "H", ]$PROPDMG * 10^2
tidystormData[tidystormData$PROPDMGEXP == "K", ]$PROPDMGNUM = tidystormData[tidystormData$PROPDMGEXP == "K", ]$PROPDMG * 10^3
tidystormData[tidystormData$PROPDMGEXP == "M", ]$PROPDMGNUM = tidystormData[tidystormData$PROPDMGEXP == "M", ]$PROPDMG * 10^6
tidystormData[tidystormData$PROPDMGEXP == "B", ]$PROPDMGNUM = tidystormData[tidystormData$PROPDMGEXP == "B", ]$PROPDMG * 10^9

# Convert H, K, M, B units to calculate Crop Damage
tidystormData$CROPDMGNUM = 0

tidystormData[tidystormData$CROPDMGEXP == "H", ]$CROPDMGNUM = tidystormData[tidystormData$CROPDMGEXP == "H", ]$CROPDMG * 10^2
tidystormData[tidystormData$CROPDMGEXP == "K", ]$CROPDMGNUM = tidystormData[tidystormData$CROPDMGEXP == "K", ]$CROPDMG * 10^3
tidystormData[tidystormData$CROPDMGEXP == "M", ]$CROPDMGNUM = tidystormData[tidystormData$CROPDMGEXP == "M", ]$CROPDMG * 10^6
tidystormData[tidystormData$CROPDMGEXP == "B", ]$CROPDMGNUM = tidystormData[tidystormData$CROPDMGEXP == "B", ]$CROPDMG * 10^9

Top 3 events causing damage to property:

damageProp <- sort(
  tapply(tidystormData$PROPDMGNUM, tidystormData$EVTYPE, sum),
  decreasing = T)

max(damageProp)
## [1] 144657709800

Top 3 events causing damage to crops:

damageCrop <- sort(
  tapply(tidystormData$CROPDMGNUM, tidystormData$EVTYPE, sum),
  decreasing = T)

max(damageCrop)
## [1] 13972566000

Top 3 events causing damage to property and crops collectively:

tidystormData$ECONDMGNUM = tidystormData$PROPDMGNUM + tidystormData$CROPDMGNUM

damageEcon <- sort(
  tapply(tidystormData$ECONDMGNUM, tidystormData$EVTYPE, sum),
  decreasing = T)

max(damageEcon)
## [1] 150319678250
# PlotB: Made up of 3 plots (create 1x3, arrange row-wise)
# Plot1: Top 3 events causing damage to property
# Plot2: Top 3 events causing damage to crops
# Plot3: Top 3 events causing damage to property and crops collectively:

par(mfrow=c(1,3), mar=c(4,4,2,1), oma=c(0,0,2,0))
with(tidystormData, {
        # Plot1
        barplot(head(damageProp,3),
        main = "Top 3 Most Harmful Events causing Property Damage",
        xlab = "Event Type",
        ylab = "Property Damage")
        
        # Plot2
        barplot(head(damageCrop,3),
        main = "Top 3 Most Harmful Events causing Crop Damage",
        xlab = "Event Type",
        ylab = "Crop Damage")
        
        # Plot3
        barplot(head(damageEcon,3),
        main = "Top 3 Most Harmful Events causing Property and Crop Damage",
        xlab = "Event Type",
        ylab = "Economic Damage")
}
)

dev.copy(png,'plotB.png')
## quartz_off_screen 
##                 3
dev.off()
## quartz_off_screen 
##                 2

The most harmful events with respect to economic damage (right-most graph) are FLOOD, HURRICANE/TYPHOON, and TORNADO.

Results

From the public health standpoint, the most harmful event causing both fatalities and injuries is the TORNADO causing significantly high casualties compared to other events.

From the economic standpoint, the most harmful event causing property damage is the FLOOD, and the most harmful event causing crop damage is the DROUGHT. However, weather events causing property damage has a larger impact on the economy, with a higher damage measured in terms of dollars value.