Introduction to R! for Actuaries Histograms

Slides:



Advertisements
Similar presentations
Creating Flash without Flash A brief introduction to Anim-FX by Michael Mina.
Advertisements

PHP Sample Application Simple graphics and database.
Actuarial Modeling in R CAS Predictive Modeling Seminar Las Vegas October, 2007 Glenn Meyers, FCAS, MAAA Jim Guszcza, FCAS, MAAA.
Important Irvine Library Procedures Randomize Randomize –Initializes the seed of the random-number formula by both the Random32 and the RandomRange procedures.
Roger L. Runquist Western Illinois University Roger L. Runquist Western Illinois University Photoshop Basics.
Creating the Pages Part Four Typography. Type Design Principles Choose fewer fonts and sizes Choose fewer fonts and sizes Choose available fonts Choose.
A Visual Introduction to PC SAS. Start SAS by double-clicking on the SAS icon...
POWERPOINT GUIDELINES For use during Telematic broadcasts.
The NetBeans IDE CSIS 3701: Advanced Object Oriented Programming.
Lesson 10. Example - tag This heading uses a 30-point font This sentence will have 30-point font This heading, too.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 1B Introduction (Tutorial)
Actuarial Modeling in R CAS Spring Meeting June, 2007 Glenn Meyers, FCAS, MAAA Jim Guszcza, FCAS, MAAA.
Preventing Automated Use of STMP Reservation System Using CAPTCHA.
FusionInspector & FusionInspectorWeb Galaxy-integration.
Deliverable 10. Deliverable #10 Class Design and Implementation #1 due 9 April Executive Summary and Statement of Work Iteration Plan (Updated) for remaining.
1 Reserving Ranges and Acceptable Deviations CANE Fall 2005 Meeting Kevin Weathers FCAS, MAAA The Hartford This document is designed for discussion purposes.
Exercise 1: IF/ELSE Step 1: Open NotePad++ and create “number.php” in your webspace Step 2: Write codes to do the following 1.Generate a random number.
Dancing With Dirty Data: Methods for Exploring and Cleaning Data 2005 CAS Ratemaking Seminar Louise Francis, FCAS, MAAA Francis Analytics and Actuarial.
Session C7: Dynamic Risk Modeling Loss Simulation Model Working Party Goals & Progress Report Mark R. Shapland, FCAS, ASA, MAAA Consulting Actuary Casualty.
Actuarial Applications of Multifractal Modeling 1 Introduction and Spatial Applications John A. Major, ASA, MAAA Guy Carpenter & Co., Inc.
Processing == Java + Extra Utilities Processing Adds: – Drawing functions – Text and font manipulations – Image and video – 3D transformations – Keyboard.
Try Coding!. Nested Frames tag attributes tag attributes Autostart=“False” Loop=“3” Hidden=“True”
Computer Graphics Lecture 1. Books D. Hearn, M. P. Baker, "Computer Graphics with OpenGL", 3rd Ed., Prentice Hall, 2003, ISBN
Distinguishing “BEST ESTIMATES” from “best estimates”
Albany, State University
POWERPOINT GUIDELINES
www 123 hp com setup hp com setup :
www 123 hp com setup 8710 Call Here:
www 123 hp com setup 4650 Printer Support Call:
www 123 hp com setup hp com setup :
www 123 hp com setup 8710 Call Here:
www 123 hp com setup hp com setup :
www 123 hp com setup 8710 Call Here:
www 123 hp com setup hp com setup :
www 123 hp com setup hp com setup :
www 123 hp com setup 8710 Call Here:
and place barcode on bottom right or left of image with move tool
Your Poster Title Goes Here
Your Poster Title Goes Here
Title of Tutorial list the Authors and affiliations here
الأستاذ المساعد بقسم المناهج وطرق التدريس
P O S T E R T I T L E Authors & Institutions
Your Poster Title Goes Here
Your Poster Title Goes Here
Your Poster Title Goes Here
Your Title Goes Here (and your subtitle here)
Your Poster Title Goes Here
Introduction Participants Results Results (continued)
Your Title Goes Here (and your subtitle here)
Your Poster Title Goes Here
Your Poster Title Goes Here
Systems Practice Use the next slide in this powerpoint as a template to identify 10 different types of systems. 4 of your slides need to be natural systems.
Your Title Goes Here (and your subtitle here)
Your Poster Title Goes Here
Your Poster Title Goes Here
Your Poster Title Goes Here
Introduction Participants Results Results (continued)
Your Title Goes Here (and your subtitle here)
Your Poster Title Goes Here
Title list the Authors and affiliations here Optional Company Logo
Your Title Goes Here (and your subtitle here)
Your Title Goes Here (and your subtitle here)
POWERPOINT GUIDELINES
Your Poster Title Goes Here
Title Introduction: Discussion & Conclusion: Methods & Results:
POWERPOINT GUIDELINES
Your Title Goes Here (and your subtitle here)
POWERPOINT GUIDELINES
POWERPOINT GUIDELINES
Your Poster Title Goes Here
Presentation transcript:

Introduction to R! for Actuaries Histograms R! Working Party Introduction to R! for Actuaries Histograms Avraham Adler, FCAS, MAAA

Introduction to R! for Actuaries Histograms It is often useful to view histograms of loss severity on both regular and logged scales There are many ways to do so using R! Following are two methods, one using the MASS package and the other using the more sophisticated ggplot2 package R! code will be displayed in Courier New font, and can be copied directly into R! to generate results R! text outputs will be displayed in blue-colored Courier New

Histograms Generating losses For demonstration purposes, the actuar package will be used to generate a suite of losses Fixing the initial random seed ensures reproducibility set.seed(216) library(actuar) Claims<-rgenpareto(n=1000, shape1=2.7, shape2=1.4, scale=1e6) summary(Claims) Min. 1st Qu. Median Mean 3rd Qu. Max. 1905 175900 417100 843900 932800 35240000

Histograms Using MASS

Using MASS Introduction and R! Code The MASS package has some simple, but useful formulæ to generate histograms library(MASS) par(mfrow=c(2,1)) truehist(Claims) lines(density(Claims), col="red", lwd=2) truehist(log10(Claims)) lines(density(log10(Claims)), col="red", lwd=2)

Using MASS Results

Histograms Using ggplot2

Using ggplot2 Introduction The ggplot2 package is both much more complicated and powerful ggplot2 requires data frames and not merely vectors The initial “plot” is created, and then layers are added or adjusted Viewports are used to show multiple plots on the same device The plot including histogram and density will be created first, and then a new scale can be overlaid on it for the second version

Using ggplot2 R! Code library(ggplot2) ClaimsDF<-data.frame(Claims) Hist<-ggplot(ClaimsDF, aes(x=Claims)) Hist1<-Hist + geom_histogram(aes(y=..density..), colour="black", fill="dodgerblue") + stat_density(color="red", size=1, geom="line") Hist2<-Hist1+scale_x_log10() vplayout <- function(x, y) viewport(layout.pos.row=x, layout.pos.col=y) grid.newpage() pushViewport(viewport(layout=grid.layout(2,1))) print(Hist1, vp=vplayout(1,1)) print(Hist2, vp=vplayout(2,1))

Using ggplot2 Results

Histograms References Dutang, C.; Goulet, V. & Pigeon, M. “actuar: An R Package for Actuarial Science.” Journal of Statistical Software (2008) R Development Core Team. R: A language and environment for statistical computing. R Foundation for Statistical Computing:Vienna, Austria. 2010 Venables, W. N. & Ripley, B. D. Modern Applied Statistics with S. New York:Springer-Verlag, 2002 Wickham, H., ggplot2: Elegant Graphics for Data Analysis. New York:Springer Science+Business Media, Inc., 2009

www.guycarp.com