Synopsys. In this document we show a descriptive analysis of the storm data, from the National Weather Service. We found that the event type with the most fatalities is the tornado. However, the number of fatalities and even injuries are highly asymmetric, a problem that should be taken into account. We found also that the tornado is the event type with the highest property damage.

Data Processing

Loading Libraries

We’ll use dplyr for data manipulation and ggplot2 to create the plots. We will also use knitr‘s kable function to render tables, scales’ dollar function and lubridate to deal with dates.

library(dplyr)
## 
## Attaching package: 'dplyr'
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(knitr)
library(ggplot2)
library(lubridate)
library(scales)

Reading data

Ensure that the repdata-data-StormData.csv.bz2 file is under your working directory.

fname <- 'repdata-data-StormData.csv.bz2'
if(file.exists(fname)) {
  storm <- read.csv(fname, stringsAsFactors = FALSE)
}
# tbl_df has a better print method for large databases.
storm <- tbl_df(storm)

Some initial analysis

The storm data has 902297 rows and 37 columns.

The events in the dataset start in the year of 1950 and end in November 2011. The table below shows the number of events in each year.

yr <- storm %>%
  mutate(yr = year(mdy_hms(BGN_DATE))) %>%
  count(yr) 
# This is a small code to make the table look better.
yr1 <- filter(yr, yr <= 1980)
yr2 <- filter(yr, yr > 1980)
yr <- bind_cols(yr1, yr2)
names(yr) <- rep(c('year', 'count'), 2)
kable(yr)
year count year count
1950 223 1981 4517
1951 269 1982 7132
1952 272 1983 8322
1953 492 1984 7335
1954 609 1985 7979
1955 1413 1986 8726
1956 1703 1987 7367
1957 2184 1988 7257
1958 2213 1989 10410
1959 1813 1990 10946
1960 1945 1991 12522
1961 2246 1992 13534
1962 2389 1993 12607
1963 1968 1994 20631
1964 2348 1995 27970
1965 2855 1996 32270
1966 2388 1997 28680
1967 2688 1998 38128
1968 3312 1999 31289
1969 2926 2000 34471
1970 3215 2001 34962
1971 3471 2002 36293
1972 2168 2003 39752
1973 4463 2004 39363
1974 5386 2005 39184
1975 4975 2006 44034
1976 3768 2007 43289
1977 3728 2008 55663
1978 3657 2009 45817
1979 4279 2010 48161
1980 6146 2011 62174

The complete documentation for this dataset can be found here

There are 985 different types of events. The table below shows the 15 most frequent types of events.

storm %>%
  count(EVTYPE, sort = TRUE) %>%
  head(15) %>%
  kable
EVTYPE n
HAIL 288661
TSTM WIND 219940
THUNDERSTORM WIND 82563
TORNADO 60652
FLASH FLOOD 54277
FLOOD 25326
THUNDERSTORM WINDS 20843
HIGH WIND 20212
LIGHTNING 15754
HEAVY SNOW 15708
HEAVY RAIN 11723
WINTER STORM 11433
WINTER WEATHER 7026
FUNNEL CLOUD 6839
MARINE TSTM WIND 6175

We can also study the data geographically. The data was filtered to observations inside the US main territories to simplify the visualization. We can see that the points were confined into a grid.

storm %>%
  filter(!is.na(LATITUDE), !is.na(LONGITUDE),
         LATITUDE < 7500, LATITUDE > 2000,
         LONGITUDE > 5000, LONGITUDE < 12500) %>%
  ggplot(aes(x = LONGITUDE, y = LATITUDE, colour = factor(STATE__))) +
  geom_point(alpha = .01) +
  guides(colour=FALSE) +
  coord_equal() +
  theme_minimal()
Storms in the US from 1950 to 2011.

Storms in the US from 1950 to 2011.

Results

Relationship between event type and population health

Now we are calculating the total fatalities by event type, and the average and median number of injuries per event type.

summ <- storm %>%
  group_by(EVTYPE) %>%
  summarise(total_fatalities = sum(FATALITIES),
            median_injuries = median(INJURIES),
            mean_injuries = mean(INJURIES),
            min_injuries = min(INJURIES),
            max_injuries = max(INJURIES),
            sd_injuries = sd(INJURIES),
            n_events = n()) %>%
  mutate(prop = total_fatalities / sum(total_fatalities * 100))

Note that the type of natural disaster that causes the most deaths is the Tornado. However, it corresponds to less than 1% of the fatalities. We reccomend to create a new classification of event type so that we can get a fewer number of types.

summ %>% 
  arrange(desc(total_fatalities)) %>% 
  select(EVTYPE, total_fatalities, prop) %>%
  head(15) %>%
  kable
EVTYPE total_fatalities prop
TORNADO 5633 0.0037194
EXCESSIVE HEAT 1903 0.0012565
FLASH FLOOD 978 0.0006458
HEAT 937 0.0006187
LIGHTNING 816 0.0005388
TSTM WIND 504 0.0003328
FLOOD 470 0.0003103
RIP CURRENT 368 0.0002430
HIGH WIND 248 0.0001638
AVALANCHE 224 0.0001479
WINTER STORM 206 0.0001360
RIP CURRENTS 204 0.0001347
HEAT WAVE 172 0.0001136
EXTREME COLD 160 0.0001056
THUNDERSTORM WIND 133 0.0000878

Look that there are many events without any injuries or deaths, hence the distribution of injuries and deaths are highly asymmetric. The table below shows descriptive statistics of the number of injuries by event type, considering only event types with more than 50 observations, ordered by the average number of injuries.

summ %>% 
  filter(n_events > 50) %>%
  arrange(desc(mean_injuries)) %>%
  select(EVTYPE, n_events,
         min_injuries,
         median_injuries, 
         mean_injuries,
         sd_injuries,
         max_injuries) %>%
  head(15) %>%
  kable
EVTYPE n_events min_injuries median_injuries mean_injuries sd_injuries max_injuries
HURRICANE/TYPHOON 88 0 0 14.4886364 89.804128 780
HEAT WAVE 74 0 0 4.1756757 24.047532 200
EXCESSIVE HEAT 1678 0 0 3.8885578 26.125838 519
HEAT 767 0 0 2.7379400 20.336475 230
ICE 61 0 0 2.2459016 9.907330 62
TORNADO 60652 0 0 1.5060674 17.179167 1700
FOG 538 0 0 1.3643123 6.013113 78
DUST STORM 427 0 0 1.0304450 4.293954 40
ICE STORM 2006 0 0 0.9845464 35.066766 1568
RIP CURRENTS 304 0 0 0.9769737 3.318534 35
WINTRY MIX 90 0 0 0.8555556 7.601835 72
COLD 72 0 0 0.6666667 2.988240 21
RECORD HEAT 81 0 0 0.6172840 5.555556 50
RIP CURRENT 470 0 0 0.4936170 1.203655 10
TROPICAL STORM 690 0 0 0.4927536 8.087553 200

Relationship between event type and economic problems

Here we show the total property damages by event type. Again, tornado appears to be the worst natural disaster. We can see also that the damages are asymmetric, as the medians are much below the means.

# property damage
storm %>%
  group_by(EVTYPE) %>%
  summarise(total_propdmg = sum(PROPDMG),
            max_propdmg = max(PROPDMG),
            mean_propdmg = mean(PROPDMG),
            median_propdmg = median(PROPDMG)) %>%
  arrange(desc(total_propdmg)) %>%
  mutate_each(funs(dollar(.)), ends_with('propdmg')) %>%
  head(15) %>%
  kable
EVTYPE total_propdmg max_propdmg mean_propdmg median_propdmg
TORNADO $3,212,258 $4,410.00 $52.96 $2.50
FLASH FLOOD $1,420,125 $5,000.00 $26.16 $0.00
TSTM WIND $1,335,966 $990.00 $6.07 $0.00
FLOOD $899,938 $3,000.00 $35.53 $0.00
THUNDERSTORM WIND $876,844 $5,000.00 $10.62 $0.60
HAIL $688,693 $970.00 $2.39 $0.00
LIGHTNING $603,352 $1,000.00 $38.30 $5.00
THUNDERSTORM WINDS $446,293 $900.00 $21.41 $0.50
HIGH WIND $324,732 $3,000.00 $16.07 $0.00
WINTER STORM $132,721 $970.00 $11.61 $0.00
HEAVY SNOW $122,252 $950.00 $7.78 $0.00
WILDFIRE $84,459 $1,000.00 $30.59 $0.00
ICE STORM $66,001 $989.00 $32.90 $0.00
STRONG WIND $62,994 $1,000.00 $17.67 $3.00
HIGH WINDS $55,625 $700.00 $36.29 $0.00