Actuarial Outpost
 
Go Back   Actuarial Outpost > Actuarial Discussion Forum > Property - Casualty / General Insurance
FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions

Salary Surveys
Property & Casualty, Life, Health & Pension

Health Actuary Jobs
Insurance & Consulting jobs for Students, Associates & Fellows

Actuarial Recruitment
Visit DW Simpson's website for more info.
www.dwsimpson.com/about

Casualty Jobs
Property & Casualty jobs for Students, Associates & Fellows


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-20-2017, 10:44 AM
ronaldy27's Avatar
ronaldy27 ronaldy27 is offline
Member
CAS
 
Join Date: Jan 2012
Location: 'Murica
Studying for the credential
Posts: 3,056
Default mapping in R (cat modelling?)

Hi,
I am trying to find a way to organize all the insureds by where they live within the US, perhaps group them by a fixed area using Longitude and Latitude so that if a natural disaster were to happen in certain regions, I can analyse the "total insureds value" impact on the insureds located in the areas.

I went over documentations for some mapping packages in R but I am kind of lost. I know the "maps" allow you to group regions by counties, states,etc. However, is there a way for me to add data into those regions?

I'm a newbie in R and I would appreciate it if anyone could provide me with a direction as to how to go about this project.
__________________
Spoiler - for size:



Reply With Quote
  #2  
Old 12-20-2017, 11:04 AM
Klaymen's Avatar
Klaymen Klaymen is offline
Member
CAS
 
Join Date: Oct 2001
Studying for AINS 21 & 22
Posts: 19,322
Default

Although I use the maps package, it is not very sophisticated. It gets me nice color maps by state and county, and I can lay overlay text or values and show a title and a legend.
I would like to learn the more sophisticated methods but it just hasn't been worth the time to me yet. I doubt that it will adequately meet your needs (i.e. lat and long), but it is an easy place to get started. I think you'll want ggplot2 but there is much more involved. (if someone else wants to provide code I would appreciate it)

Here's some sample code for the maps program. Copying the information directly from the screen didn't look right but if you go to the source of this message (quote it) it should work.

library(maps)
library(mapdata)

countycol<-cbind(
"#b35806","#b35806","#b35806","#d8daeb","#fee0b6", "#fee0b6","#998ec3","#998ec3","#542788","#d8daeb", "#b35806","#f1a340","#b35806","#d8daeb","#542788", "#542788","#998ec3","#f1a340","#998ec3","#fee0b6", "#b35806","#f1a340","#b35806","#b35806","#b35806", "#d8daeb","#d8daeb","#542788","#fee0b6","#f1a340", "#b35806","#b35806","#542788","#f1a340","black","# 542788","#542788","#b35806","#f1a340","#b35806","# b35806","#998ec3","#f1a340","#b35806","#d8daeb","# f1a340","#542788","#998ec3","#fee0b6","#542788","# 998ec3","#b35806","#f1a340","#998ec3","#fee0b6","# b35806","#542788","#b35806","#b35806","#fee0b6","# d8daeb","#542788","#542788","#d8daeb","#b35806","# 542788","black","#d8daeb","#d8daeb","#d8daeb","#d8 daeb","black","#fee0b6","#b35806","#f1a340","#d8da eb","#f1a340","black","#542788","#998ec3","#542788 ","#d8daeb","#b35806","#f1a340","#542788","#b35806 ","#d8daeb","#d8daeb","#b35806","#f1a340","#f1a340 ","#542788","#998ec3","#542788","#542788","#542788 ","#542788","#998ec3","#b35806","#b35806","#542788 ","#f1a340","#d8daeb","black","#f1a340","#b35806", "#f1a340","#f1a340","#fee0b6","#542788","#542788", "#542788","#f1a340","#b35806","#f1a340"
)

map('county','missouri',fill=TRUE,col=countycol)
title("American Family Missouri Outbuilding Relativities")
map.text('county','missouri',col="black",add=TRUE, cex=0.50)
legend(x='topright',legend = c("1.00","1.249","1.343","1.737","2.252","3.465"," N/A"),cex=1.00,
fill=cbind(
"#542788",
"#998ec3",
"#d8daeb",
"#fee0b6",
"#f1a340",
"#b35806",
"black"
))
__________________



Last edited by Klaymen; 12-20-2017 at 11:12 AM..
Reply With Quote
  #3  
Old 12-20-2017, 11:08 AM
ronaldy27's Avatar
ronaldy27 ronaldy27 is offline
Member
CAS
 
Join Date: Jan 2012
Location: 'Murica
Studying for the credential
Posts: 3,056
Default

Quote:
Originally Posted by Klaymen View Post
Although I use the maps package, it is not very sophisticated. It gets me nice color maps by state and county, and I can lay overlay text or values and show a title and a legend.
I would like to learn the more sophisticated methods but it just hasn't been worth the time to me yet.
Yeah, I'm a newbie in this and even I knew maps was not going to help me get far. I did find another documentation for mapping in R: "Introduction to visualising spatial data in R"

This one went a little more in depth.
__________________
Spoiler - for size:



Reply With Quote
  #4  
Old 12-20-2017, 11:14 AM
ronaldy27's Avatar
ronaldy27 ronaldy27 is offline
Member
CAS
 
Join Date: Jan 2012
Location: 'Murica
Studying for the credential
Posts: 3,056
Default

https://www.coursera.org/learn/r-data-visualization

Starts on Dec 25, on Christmas, if anyone is as lonely as I am and is interested in learning about mapping.

This might help me do this project.
__________________
Spoiler - for size:



Reply With Quote
  #5  
Old 12-20-2017, 11:59 AM
Klaymen's Avatar
Klaymen Klaymen is offline
Member
CAS
 
Join Date: Oct 2001
Studying for AINS 21 & 22
Posts: 19,322
Default

nice humblebrag about being lonely.
__________________


Reply With Quote
  #6  
Old 12-20-2017, 12:11 PM
Tacoactuary's Avatar
Tacoactuary Tacoactuary is offline
Member
CAS Non-Actuary
 
Join Date: Nov 2014
Location: Des Moines, IA
College: Vanderbilt, UIUC
Favorite beer: Yazoo Sue
Posts: 1,131
Default

In just the past few months I built a Shiny app to help visualize information related to a territorial rate review. It uses leaflet for interactive choropleths and plotly for interactive graphs. Let me know if you have any questions.
Attached Images
 
__________________
ACAS 7 8 9
Reply With Quote
  #7  
Old 12-20-2017, 01:04 PM
ronaldy27's Avatar
ronaldy27 ronaldy27 is offline
Member
CAS
 
Join Date: Jan 2012
Location: 'Murica
Studying for the credential
Posts: 3,056
Default

Quote:
Originally Posted by Tacoactuary View Post
In just the past few months I built a Shiny app to help visualize information related to a territorial rate review. It uses leaflet for interactive choropleths and plotly for interactive graphs. Let me know if you have any questions.
That's some good stuff. I didn't even know what "Shiny" was until now.
I found a website with tutorial videos. Are they completely free?
__________________
Spoiler - for size:



Reply With Quote
  #8  
Old 12-20-2017, 01:24 PM
Tacoactuary's Avatar
Tacoactuary Tacoactuary is offline
Member
CAS Non-Actuary
 
Join Date: Nov 2014
Location: Des Moines, IA
College: Vanderbilt, UIUC
Favorite beer: Yazoo Sue
Posts: 1,131
Default

Quote:
Originally Posted by ronaldy27 View Post
That's some good stuff. I didn't even know what "Shiny" was until now.
I found a website with tutorial videos. Are they completely free?
Yes. Shiny, leaflet, and plotly are open source under various licenses of and free for commercial use subject to each licence's requirements.
__________________
ACAS 7 8 9
Reply With Quote
  #9  
Old 12-22-2017, 01:18 AM
AbedNadir's Avatar
AbedNadir AbedNadir is offline
Member
CAS SOA
 
Join Date: Mar 2014
Studying for enlightenment
Posts: 2,124
Default

Quote:
Originally Posted by Tacoactuary View Post
In just the past few months I built a Shiny app to help visualize information related to a territorial rate review. It uses leaflet for interactive choropleths and plotly for interactive graphs. Let me know if you have any questions.
dope
__________________
Reply With Quote
  #10  
Old 12-20-2017, 01:16 PM
cowactuary cowactuary is offline
Member
SOA
 
Join Date: Dec 2011
Studying for FAP
Posts: 105
Default

Look at the ggmap package
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -4. The time now is 10:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
*PLEASE NOTE: Posts are not checked for accuracy, and do not
represent the views of the Actuarial Outpost or its sponsors.
Page generated in 0.24562 seconds with 10 queries