29
Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 [email protected] 860-954-0894

Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 [email protected]

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

Creating more Analytical Bandwidth with R

Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011

[email protected] 860-954-0894

Page 2: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

R2SAS - Background Travelers is a multi-line top 10 P&C Insurance Carrier – experiencing recent rapid growth in Analytics

Travelers Analytics – 5+ Research Depts., SAS User Group 550+ members, approx. 120 JMP seats (from 0 in two years), and 50-80 current R users

My Role – Modeling, Consulting, & Tool-building

Motivation – All data is on UNIX (AIX & Linux) SAS Servers & variety of databases

Need – Two Groups – 1) Some Experienced modelers are experimenting with R stats, 2) New grads with only R background need quickly to get up to speed with SAS to be productive – currently data access in all manual.

How – R package for (D)COM enables access to JMP Automation and SAS/IT

Page 3: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

3

JMP 9 – R Connection (Main Menu(“Help: Scripting Index: R Connection”) )

Page 4: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

4

Introducing r2SAS – R – JMP Connection

Page 5: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

5

R – JMP Connection - usage - Load the r2SAS library (collection of functions)

Page 6: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

6

r2SAS – functions to connect to JMP and SAS

Page 7: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

7

Connect to JMP - open an existing JMP data table

Page 8: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

8

JMP VB Automation docs – OpenDocument(“filename”)

Page 9: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

9

Connect to JMP – run some JSL

Page 10: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

10

Create and execute a JSL script from disk

Page 11: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

11

Create a new JMP data table & populate it with data

Page 12: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

12

Return JMP Formula Column back to R from the JMP Table

Page 13: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

13

Via JMP, we can push R data to a JMP table & on through to SAS

Page 14: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

14

Send R data to JMP, submit JSL, Fit Model calculating new column, bring back to R

Page 15: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

15

Send R data to JMP, submit JSL, Fit Model calculating new column, bring back to R

Page 16: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

16

Launch a platform

Page 17: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

17

Pause for Questions?

r2SAS – on to connecting with SAS

Page 18: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

18

Connect to local PC SAS & directly submit SAS code

Page 19: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

19

Connect to local PC SAS & Submit existing SAS program

Page 20: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

20

Returned is the SAS log and listing – SAS Datasets can then be Imported into R vectors & data frames

Page 21: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

21

Return the result data to R as a data frame & graph

Page 22: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

22

example call – connect to UNIX SAS

Page 23: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

23

Run an existing program on the server, (passing parameters)

Page 24: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

24

Submit SAS code to the SAS server

Page 25: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

25

And return SAS data to R on desktop

Page 26: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

26

r2SAS v0.1 – to do’s – a lot

Add error checking (current very little) Perhaps a GUI in R to submit code for demo Submit local SAS program file on remote sever Return SAS output as HTML/PDF/etc – (requires Creating a SAS result package) Async submit Return a graph from JMP to R Return R data directly to SAS Better model examples Your suggestion here…

Page 27: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

27

r2SAS

Contact info: Matt Flynn – Travelers [email protected] 860.954.0894

Thank you – Questions?

Page 28: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

28

Appendix – resources

Page 29: Creating more Analytical Bandwidth with R...Creating more Analytical Bandwidth with R Matthew J. Flynn, PhD Predictive Analytics World, New York City, October 20, 2011 mjflynn@travelers.com

29

Appendix – resources

# NESUG 2010 Multiple Methods in JMP® to Interact with R # http://www.nesug.org/Proceedings/nesug10/po/po06.pdf # NESUG 2009 Automating JMP via Scripting tools and MS Windows COM # http://www.nesug.org/Proceedings/nesug09/ap/ap09.pdf # Usage Note 11089: How to enable JMP as a single use server for automation # http://www.jmp.com/support/notes/11/089.html # See also: # # GetObject and CreateObject behavior of Office automation servers # http://support.microsoft.com/kb/288902 # How to obtain the window handle for an Office Automation server # http://support.microsoft.com/kb/258511 # http://communities.sas.com/message/47978#47978