Statistics 4868/6610 Data Visualization
Prof. Eric A. Suess
2/1/2015
Today in the computer lab we will go over some examples of time series data using
The Hot Dog Eating example gives a good idea how to work with R to make bargraphs.
Try the author's program bars.R
Reproduce the graph from bars.R that is on page 96 using tableau.
First note that the hot-dogs-contest-winners.csv file is considered a Text File by tableau.
The Columns shelf will be Year and the Rows shelf will be SUM(Dogs eaten).
To color code the years with a new recoded, drag New record to the Marks Color.
Now produce a map movie of the Hot Dog Eating data showing the changing country of origin by time.
Longitude is the Column
Latitute if the Row
And Year is the Pages
The Hot Dog Eating example gives a good idea how to work with R to make bargraphs.
Try the author's program stackedbars.R
The FlowingData Subscribers example give a good idea of how to work with R to make time plots.
Try the author's program scatter.R
What does type=“h” do in a plot() command?
What does the points() command do?
Now reproduce the graph from scatter.R that is on page 116 using tableau.
First note that the flowingdata_subscribers.csv file is considered a Text File by tableau.
The Columns shelf will be DAY(Date) and the Rows shelf will be SUM(Subscribers).
Change the Marks to Bar and change the Size.
Reproduce the graph from timeseries.R that is on page 120 using tableau.
The US Postage example gives a good idea how to work with R to make step charts.
A step chart is for data in time that changes at a spcific time. US Postage rates change on specific dates.
Try the author's program step.R
Reproduce the plots on page 126.
What does type=“s” do in a plot() command?
What does the points() command do?
When looking at time series data it is common to examine time series plots for an underlying trend. The trend may linear or nonliear or may be periodic.
The use of linear regression is common to see linear and nonlinear (quadratic, cubic, etc.) trends.
The use of LOESS is commonly used when the data is not periodic. LOESS is locally weighted scatterplot smoothing.
LOESS gives an easy way to smooth the data. Small slices are fitted with a low-degree polynomial, then the small curves a put together.
The Unemployment example gives a good idea how to work with R to smooth time series data using LOESS.
Try the author's program loess.R
What does the function lines() do?
What does the function scatter.smooth() do?
Basic models
Additive model
\( Y_t = T_t + S_t + I_t \)
Multiplicative model
\( Y_t = T_t * S_t * I_t \)
What would a log transformation to to the multiplicative model?
In R
decompose( )
library(astsa)
plot(jj, type="o", ylab="Quarterly
Earnings per Share")
library(astsa)
plot(log(jj), type="o", ylab="Quarterly
Earnings per Share")
plot(decompose(jj))
acf(jj)
pacf(jj)