Introduction to CAS RPM Seminar Steve Berman, FCAS, MAAA March 19, - - PDF document

introduction to
SMART_READER_LITE
LIVE PREVIEW

Introduction to CAS RPM Seminar Steve Berman, FCAS, MAAA March 19, - - PDF document

3 / 1 5 / 2 0 1 2 Introduction to CAS RPM Seminar Steve Berman, FCAS, MAAA March 19, 2012 Jim Guszcza, FCAS, MAAA R Graphics Charts Scatterplots Histograms Boxplots Other visualizations 1 3 / 1 5 / 2 0 1 2 R Graphics R offers


slide-1
SLIDE 1

3 / 1 5 / 2 0 1 2 1

Introduction to

CAS RPM Seminar March 19, 2012 Steve Berman, FCAS, MAAA Jim Guszcza, FCAS, MAAA

R – Graphics

Charts Scatterplots Histograms Boxplots Other visualizations

slide-2
SLIDE 2

3 / 1 5 / 2 0 1 2 2

2

R Graphics

  • R offers a large versatility in graphics. It’s easy to create a

simple plot, but graphs can be customized in ways that are hard to do in Excel or most applications

Hint: you can alw ays click “ctrl-l” to clear the screen

3

plot

  • plot is the simplest graphics command. It’s a generic

plotting function. Creates a graphics frame and allows drawing of data series. Can create quick plots or customize the output

– Chart type (type) – Titles (main, sub) – Axes (axis) – Legends (legend) – Colors (col) – Sizes (lwd, cex) – Data labels (text, mtext)

  • lines draws additional lines on an existing graph
  • par controls graphical parameters

Hint: you can alw ays click “ctrl-l” to clear the screen

slide-3
SLIDE 3

3 / 1 5 / 2 0 1 2 3

4

Bar charts

  • Use barplot function, similar to plot
  • Grouped bars
  • Stacked bars
  • Vertical or horizontal

Hint: you can alw ays click “ctrl-l” to clear the screen

5

Exercise

  • Create a bar chart showing losses by accident month
  • Extra credit: split by coverage, 2007 only

Hint: you can alw ays click “ctrl-l” to clear the screen

slide-4
SLIDE 4

3 / 1 5 / 2 0 1 2 4

6

Histograms

  • There are several functions for creating simple histograms

– hist – truehist

  • Can adjust size of bins, color, a few other options

Hint: you can alw ays click “ctrl-l” to clear the screen

7

boxplot

  • Use to get a graphical representation of distribution
  • Show center of distributions, outliers
  • Grouping by subcategories
  • Tip: 2-D version of a boxplot exists, called a bagplot (in

aplpack library)

Hint: you can alw ays click “ctrl-l” to clear the screen

slide-5
SLIDE 5

3 / 1 5 / 2 0 1 2 5

8

Scatterplots

  • Two dimensional plot (where x axis points not ordered)
  • Use plot function (type= ‘p’) or other functions

Hint: you can alw ays click “ctrl-l” to clear the screen

9

Exercise

  • Modify the price / quantity scatterplot for the following:

– Pricing changes in January – mark all January and February dots in a different color – Change the dots so that the size of the dots is proportional to sales (under $1M, $1M-2M, $2M+ ) (size of dots using cex)

Hint: you can alw ays click “ctrl-l” to clear the screen

slide-6
SLIDE 6

3 / 1 5 / 2 0 1 2 6

10

Q-Q plots

  • To test that data came from specific distribution

– One axis is empirical distribution – One axis is theoretical distribution – This example uses plot and abline

Hint: you can alw ays click “ctrl-l” to clear the screen

11

Correlations

  • Get more information than from cor() function

– pairs – heatmap

Hint: you can alw ays click “ctrl-l” to clear the screen

ee.risk patient.risk payer.consol clinical.consol cost.control

  • a.activity

quality.init innovation

  • mmunity.activity

standardization standardization community.activity innovation quality.init

  • a.activity

cost.control clinical.consol payer.consol patient.risk ee.risk

slide-7
SLIDE 7

3 / 1 5 / 2 0 1 2 7

12

Other visualizations

  • Several packages exist which add to visualizations

– lattice – ggplot – maps – VMRLGen – Many more…

Hint: you can alw ays click “ctrl-l” to clear the screen