NOAA Storm Database Exploratory Analysis

Synopsis

This work is intended to answer some proposed questions, by analysing the US National Oceanic and Atmospheric Administration’s (NOAA) Storm database. Complete information about database can be found at Storm Data Documentation. The goal of such database is to map characteristics of storms and other weather phenomena.

More specific, those main questions are:

  • Across the United States, which types of events are most harmful with respect to population health?

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

Therefore, report explains how data are processed and at last, show results with some variety of formats, like figures and tables, for example. Main objective here is to exercise exploratory analysis data flow, Starting by collect data, feature selection and some adjustments, and finally get some first insights from data by graphical analysis.

Data processing

As input of analysis, I used the NOAA Storm Database. This database looks like these, in raw data format:

data <- read.csv('repdata-data-StormData.csv')
head(data)
##   STATE__           BGN_DATE BGN_TIME TIME_ZONE COUNTY COUNTYNAME STATE
## 1       1  4/18/1950 0:00:00     0130       CST     97     MOBILE    AL
## 2       1  4/18/1950 0:00:00     0145       CST      3    BALDWIN    AL
## 3       1  2/20/1951 0:00:00     1600       CST     57    FAYETTE    AL
## 4       1   6/8/1951 0:00:00     0900       CST     89    MADISON    AL
## 5       1 11/15/1951 0:00:00     1500       CST     43    CULLMAN    AL
## 6       1 11/15/1951 0:00:00     2000       CST     77 LAUDERDALE    AL
##    EVTYPE BGN_RANGE BGN_AZI BGN_LOCATI END_DATE END_TIME COUNTY_END
## 1 TORNADO         0                                               0
## 2 TORNADO         0                                               0
## 3 TORNADO         0                                               0
## 4 TORNADO         0                                               0
## 5 TORNADO         0                                               0
## 6 TORNADO         0                                               0
##   COUNTYENDN END_RANGE END_AZI END_LOCATI LENGTH WIDTH F MAG FATALITIES
## 1         NA         0                      14.0   100 3   0          0
## 2         NA         0                       2.0   150 2   0          0
## 3         NA         0                       0.1   123 2   0          0
## 4         NA         0                       0.0   100 2   0          0
## 5         NA         0                       0.0   150 2   0          0
## 6         NA         0                       1.5   177 2   0          0
##   INJURIES PROPDMG PROPDMGEXP CROPDMG CROPDMGEXP WFO STATEOFFIC ZONENAMES
## 1       15    25.0          K       0                                    
## 2        0     2.5          K       0                                    
## 3        2    25.0          K       0                                    
## 4        2     2.5          K       0                                    
## 5        2     2.5          K       0                                    
## 6        6     2.5          K       0                                    
##   LATITUDE LONGITUDE LATITUDE_E LONGITUDE_ REMARKS REFNUM
## 1     3040      8812       3051       8806              1
## 2     3042      8755          0          0              2
## 3     3340      8742          0          0              3
## 4     3458      8626          0          0              4
## 5     3412      8642          0          0              5
## 6     3450      8748          0          0              6

Among all those variables below, our concern is about EVTYPE, which means type of events related to population health.

names(data)
##  [1] "STATE__"    "BGN_DATE"   "BGN_TIME"   "TIME_ZONE"  "COUNTY"    
##  [6] "COUNTYNAME" "STATE"      "EVTYPE"     "BGN_RANGE"  "BGN_AZI"   
## [11] "BGN_LOCATI" "END_DATE"   "END_TIME"   "COUNTY_END" "COUNTYENDN"
## [16] "END_RANGE"  "END_AZI"    "END_LOCATI" "LENGTH"     "WIDTH"     
## [21] "F"          "MAG"        "FATALITIES" "INJURIES"   "PROPDMG"   
## [26] "PROPDMGEXP" "CROPDMG"    "CROPDMGEXP" "WFO"        "STATEOFFIC"
## [31] "ZONENAMES"  "LATITUDE"   "LONGITUDE"  "LATITUDE_E" "LONGITUDE_"
## [36] "REMARKS"    "REFNUM"

Looking closer to EVTYPE, we can see some examples of these events.

head(unique(data$EVTYPE))
## [1] TORNADO               TSTM WIND             HAIL                 
## [4] FREEZING RAIN         SNOW                  ICE STORM/FLASH FLOOD
## 985 Levels: ? ABNORMALLY DRY ABNORMALLY WET ... WND

So, to begin this analysis. We have chosen four variables: STATE, EVTYPE, FATALITIES, INJURIES and PROPDMG (property damage)

library(data.table)
harmfulEvent <- data.table(data$STATE, data$EVTYPE, data$FATALITIES, data$INJURIES, data$PROPDMG)
setnames(harmfulEvent, c('state','evtype','fatalities','injuries', 'propdmg'))
head(harmfulEvent)
##    state  evtype fatalities injuries propdmg
## 1:    AL TORNADO          0       15    25.0
## 2:    AL TORNADO          0        0     2.5
## 3:    AL TORNADO          0        2    25.0
## 4:    AL TORNADO          0        2     2.5
## 5:    AL TORNADO          0        2     2.5
## 6:    AL TORNADO          0        6     2.5

At last, we can make some aggregations in order to discover how many fatalities each state most suffer by event.

library(plyr)
ag <- harmfulEvent[, sum(fatalities), by = c('evtype','state')]
max_harm_state <- ddply(ag,~state,function(x){x[which.max(x$V1),]})
sortedHarm <- max_harm_state[order(-max_harm_state$V1),]
head(sortedHarm)
##     evtype state  V1
## 20    HEAT    IL 653
## 2  TORNADO    AL 617
## 63 TORNADO    TX 538
## 38 TORNADO    MS 450
## 37 TORNADO    MO 388
## 5  TORNADO    AR 379

Notice that state of Illinois suffers with heat, followed by Alabama, which tornado is main cause of fatalities. Similarly, same analysis can be done with injuries variable:

ag <- harmfulEvent[, sum(injuries), by = c('evtype','state')]
max_injuries_state <- ddply(ag,~state,function(x){x[which.max(x$V1),]})
sortedInjuries <- max_injuries_state[order(-max_injuries_state$V1),]
head(sortedInjuries)
##     evtype state   V1
## 63 TORNADO    TX 8207
## 2  TORNADO    AL 7929
## 38 TORNADO    MS 6244
## 5  TORNADO    AR 5116
## 49 TORNADO    OK 4829
## 62 TORNADO    TN 4748

Summary above clearly states that tornadoes are high related to injuries. Finally, we do same analysis for property damage (propdmg variable), which give us some clue about economic consequences:

ag <- harmfulEvent[, sum(propdmg), by = c('evtype','state')]
max_propdmg_state <- ddply(ag,~state,function(x){x[which.max(x$V1),]})
sortedPropdmg <- max_propdmg_state[order(-max_propdmg_state$V1),]
head(sortedPropdmg)
##     evtype state       V1
## 63 TORNADO    TX 283097.2
## 38 TORNADO    MS 187840.9
## 2  TORNADO    AL 167816.2
## 49 TORNADO    OK 165167.9
## 13 TORNADO    FL 159752.6
## 18 TORNADO    IA 152142.8

Again, tornadoes are main cause of property damage.

Results

As results, we can show histograms of previous section analysis. All plots just contain top 20 fatalities, injuries and property damages, respectivelly, grouped by state

library(ggplot2)
topFatalities <- sortedHarm[1:20,]
p <- qplot(x = topFatalities$state, y = topFatalities$V1, topFatalities, 
           color = topFatalities$evtype, geom = c('point','smooth'), method = "lm",
           xlab = "state", ylab = "num of fatalities", main = 'Num fatalities x state')
print(p, width = 100)

Injuries plot by state is very similar to above fatalities histogram:

library(ggplot2)
topInjuries <- sortedInjuries[1:20,]
p <- qplot(x = topInjuries$state, y = topInjuries$V1, topInjuries, 
           color = topInjuries$evtype, geom = c('point','smooth'), method = "lm",
           xlab = "state", ylab = "num of injuries", main = 'Num injuries x state')
print(p, width = 50)

Last plot shows relation between property damage and event type:

library(ggplot2)
topDamaged <- sortedPropdmg[1:20,]
p <- qplot(x = topDamaged$state, y = topDamaged$V1, topDamaged, 
           color = topInjuries$evtype, geom = c('point','smooth'), method = "lm",
           xlab = "state", ylab = "property damages", main = 'Property damages x state')
print(p, width = 50)