Scaling in R
-
Upload
egoodwintx -
Category
Data & Analytics
-
view
71 -
download
0
Transcript of Scaling in R
![Page 1: Scaling in R](https://reader031.fdocuments.us/reader031/viewer/2022030121/58a2a96e1a28ab0d0a8b6b7f/html5/thumbnails/1.jpg)
Scaling in R &
ggplot + forecastEd Goodwin
Houston R Users Group
![Page 2: Scaling in R](https://reader031.fdocuments.us/reader031/viewer/2022030121/58a2a96e1a28ab0d0a8b6b7f/html5/thumbnails/2.jpg)
What is scaling?Scaling is when you need to transform a dataset to
another size scale…usually to analyze with a another data set
Example: comparing two survey datasets with different scoring mechanisms
It allows you to measure the relative effects of datasets on different scales
![Page 3: Scaling in R](https://reader031.fdocuments.us/reader031/viewer/2022030121/58a2a96e1a28ab0d0a8b6b7f/html5/thumbnails/3.jpg)
Let’s make some samples
![Page 4: Scaling in R](https://reader031.fdocuments.us/reader031/viewer/2022030121/58a2a96e1a28ab0d0a8b6b7f/html5/thumbnails/4.jpg)
How do we common-size our samples?
• With the scale( ) function
• scale( ) allows you to scale and center the data
![Page 5: Scaling in R](https://reader031.fdocuments.us/reader031/viewer/2022030121/58a2a96e1a28ab0d0a8b6b7f/html5/thumbnails/5.jpg)
Scaling
Divide all column values by the standard deviation
to arrive at a common scaling
![Page 6: Scaling in R](https://reader031.fdocuments.us/reader031/viewer/2022030121/58a2a96e1a28ab0d0a8b6b7f/html5/thumbnails/6.jpg)
Centering
Subtract all column values from the column mean to
get a common center value
![Page 7: Scaling in R](https://reader031.fdocuments.us/reader031/viewer/2022030121/58a2a96e1a28ab0d0a8b6b7f/html5/thumbnails/7.jpg)
Centered & Scaled
![Page 8: Scaling in R](https://reader031.fdocuments.us/reader031/viewer/2022030121/58a2a96e1a28ab0d0a8b6b7f/html5/thumbnails/8.jpg)
You could also do this yourself (z-transform)
![Page 9: Scaling in R](https://reader031.fdocuments.us/reader031/viewer/2022030121/58a2a96e1a28ab0d0a8b6b7f/html5/thumbnails/9.jpg)
Forecast + ggplot
Recent updates to Rob Hyndman’s forecast package include ability to use ggplot for plotting time series forecasts.
See http://robjhyndman.com/hyndsight/forecast7-ggplot2/ for more details
![Page 10: Scaling in R](https://reader031.fdocuments.us/reader031/viewer/2022030121/58a2a96e1a28ab0d0a8b6b7f/html5/thumbnails/10.jpg)
Using ggplot with time seriesuse autoplot( ) function with time series objects to create ggplot graphics.