JMP and R Integration Application using Alaskan Pipeline
- Slides: 20
JMP® and R Integration Application using Alaskan Pipeline Data Melvin Alexander MAJUG Co-Chair MAJUG Meeting, Thursday, September 28, 2017
Agenda Purpose: Demonstrate and apply JMP® and R Integration functionality on Alaskan pipeline data. • Review steps and basic functions connecting JMP® with R • Compare results from both products • Conclusions • Q & A
JMP® and R Integration Application using Alaskan Pipeline Data Abstract: JMP® and R Integration is a powerful interface that facilitates communication between both environments. This interface allows JMP® to execute R commands, exchange data and output. This presentation will illustrate this capability using Alaskan Pipeline data from the NIST/SEMATECH e-Handbook of Statistical Methods, http: //www. itl. nist. gov/div 898/handbook/pmd/section 6/pmd 62. htm. The advantage of this interface allows users access to the statistical and visualization tools available in both products.
Getting Started JMP® and R (additional optional libraries as needed) must be installed on the same machine Open JMP® Script window and Log Use File > Open (select script from dialog) or File > New > Script (type or paste code in Script window) Execute R Init(); (opens R and links JMP® to R) Output written to JMP® Log and Output Windows
Basic JSL R-Integration Functions R Init(); (Connects JMP® to R) R Send(); (Sends data object, table, list, matrix, or number from JMP® to R) R Submit(“[ …R code…]”); (Executes string of R code commands) or R Submit File(/*path to the file that contains the R code you want to execute*/); (Executes externally stored string of R code commands) R Execute(/*list of R input var names*/, /*list of R output var names*/, "[your R code to submit]"); (Executes R code ) Varname = R Get(); (Brings data from R to JMP®, assigning it to Varname) or R Get Graphics(/*either png or jpg*/); (displays the most recent R plot) R Term(); (Disconnects JMP® and R link)
http: //www. itl. nist. gov/div 898/handbook/pmd/section 6/pmd 621. htm
R Code of Alaskan Pipeline Data
Open in JMP® and Use Alaskan Pipeline Data in R R Init(); /* starts connection to R */ R Submit( “[ ## Generate conditional plot ## create vector with dependent variable, field defect size fdef = c(18, 38, 15, 20, 18, 36, 20, 43, 45, 65, 43, 38, 33, 10, 50, 15, 53, 60, 18, 38, 15, 20, 18, 36, 20, 43, 45, 65, 43, 38, 33, 10, 50, 15, 53, 15, 37, 15, 18, 11, 35, 20, 40, 50, 36, 50, 38, 10, 75, 10, 85, 13, 50, 58, 48, 12, 63, 10, 63, 13, 28, 35, 63, 13, 45, 9, 20, 18, 35, 20, 38, 50, 70, 40, 21, 19, 10, 33, 16, 5, 32, 23, 30, 45, 33, 25, 12, 53, 36, 5, 63, 43, 25, 73, 45, 52, 9, 30, 22, 56, 15, 45) ## other R code etc. Batch <- as. factor(bat) df <- data. frame(fdef, ldef, Batch) len <- length(Batch) xax = “Lab Defect Size” yax = “Field Defect Size” Title =“Alaska Pipeline Ultrasonic Calibration Data” plot(ldef, fdef, xlab=xax, ylab=yax, main=title, col=“blue”) ## other R code etc. ]”); /* create JMP data table from the R data frame */ Rdf = R Get (df) ; Rdf << New. Data. View << Set Name( “R Data frame Table” ) ; /* set the Value ordering and label properties for the Batch variable so that the Graph Builder plot from JMP matches the Trellis Plot displayed from R */ Rdf: Batch << Set Property (“Value Ordering”, Eval( {4, 5, 6, 1, 2, 3} ) ) << Value Labels (1, “Batch: 1”, 2, “Batch: 2”, 3, “Batch: 3”, 4, “Batch: 4”, 5, “Batch: 5”, 6, “Batch: 6” ) << Use Value Labels(1) ; /* other JSL and R code */
Open in JMP® and Use Alaskan Pipeline Data in R (cont) /* submit another block of R code to get Trellis plot form R into a JMP Window */ R Submit( “[ # load package to produce trellis plot library (lattice) ## Generate conditionl plot trellis. device(new = TRUE, col = FALSE) FIG = xyplot(fdef ~ ldef | Batch, data=df, main = title, layout=c(3, 2), col=4, xlab=list(xax, cex=1. 1), ylab=list(yax, cex=1. 1), strip=function(…) strip. default(…, strip. names=c(T, T), FIG ]”); Picture = R Get( “png” ) ; New Window( “Alaskan Pipeline Ultrasonic Calibration Data from R into JMP”, picture ) ; Wait(10); /** Use Graph Builder to produce reproduce Trellis plot in JMP**/ Rdf = R Get (df) ; Rdf << Graph Builder( Size( 457, 408), Show Control Panel( 0 ), Variables( X ( : ldef ), Y( : fdef ), Wrap( : Batch, Levels per Row( 3 ) ) ), Elements( Point( X, Y, Legend( 3 ) ) ), Send. To. Report( Dispatch( {}, “graph title”, Text. Edit. Box, {Set Text( “Alaska Pipeline Ultrasonic Calibration Data – JMP” )} ), Dispatch( {}, “X title”, Text. Edit. Box, {Set Text( “Lab Defect Size “ )} ), Dispatch( {}, “Y title”, Text. Edit. Box, {Set Text( “ln(Field Defect Size” )} ) ) ) ; /* other JSL and R code */
Note: The TKInt. RJMP. R version 5. 05 message establishes successful connection to R. Contents in the JMP Log are the returned output that would be written in the R Console. The 0 at the end terminates the R session) Selected Results written to JMP Log that would appear in the R Console TKInt. RJMP. R version 5. 05 $`1` Call: lm(formula = y ~ x, data = x) Residuals: Min 1 Q Median 3 Q Max -8. 7219 -4. 9844 -0. 4439 3. 4162 11. 6738 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 7. 15730 2. 97737 2. 404 0. 0279 * x 0. 63269 0. 06392 9. 898 1. 8 e-08 *** --Signif. codes: 0 '***' 0. 001 '**' 0. 01 '*' 0. 05 '. ' 0. 1 ' ' 1 Residual standard error: 6. 526 on 17 degrees of freedom Multiple R-squared: 0. 8521, Adjusted R-squared: 0. 8434 F-statistic: 97. 98 on 1 and 17 DF, p-value: 1. 798 e-08 Call: lm(formula = fdef ~ ldef) Residuals: Min 1 Q Median 3 Q Max -16. 5817 -3. 8259 0. 1283 3. 7432 21. 5174 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 4. 99368 1. 12566 4. 436 2. 26 e-05 *** ldef 0. 73111 0. 02455 29. 778 < 2 e-16 *** --Signif. codes: 0 '***' 0. 001 '**' 0. 01 '*' 0. 05 '. ' 0. 1 ' ' 1 Residual standard error: 6. 081 on 105 degrees of freedom Multiple R-squared: 0. 8941, Adjusted Rsquared: 0. 8931 F-statistic: 886. 7 on 1 and 105 DF, p-value: < 2. 2 e-16 0
/* Create JMP data table from the R data frames */ Rdf = R Get(df) ; Rdf << New. Data. View << Set Name("R Data frame Table") ;
/* Produce plots and regression fits with JMP Analysis platforms */ /* Get the FIG graph from R and display in JMP */ R Submit( "[ ## Generate conditional plot trellis. device(new = TRUE, col = FALSE) FIG = xyplot(fdef ~ ldef | Batch, data=df, main = title, layout=c(3, 2), col=4, xlab=list(xax, cex=1. 1), ylab=list(yax, cex=1. 1), strip=function(. . . ) strip. default(. . . , strip. names=c(T, T))) FIG ]" ); picture = R Get Graphics( "png" ); New Window("Alaska Pipeline Ultrasonic Calibration Data from R into JMP", picture) ; Wait( 10 );
/*Set the Value ordering property for the Batch column so that it matched displaying the Trellis Plot in R Value Lables() property matches the FIG labeling from R */ Rdf: Batch << Set Property( "Value Ordering", Eval ( {4, 5, 6, 1, 2, 3} ) ) << Value Labels( {1 = "Batch: 1", 2 = "Batch: 2", 3 = "Batch: 3", 4 = "Batch: 4", 5 = "Batch: 5", 6 = "Batch: 6"} ) << Use Value Labels( 1 ) ;
Rdf << Graph Builder(Size( 457, 408 ), Show Control Panel( 0 ), Variables( X( : ldef ), Y( : fdef ), Wrap( : Batch, Levels per Row( 3 ) ) ), Elements( Points( X, Y, Legend( 3 ) ) ), Send. To. Report( Dispatch({}, "graph title", Text. Edit. Box, {Set Text( "Alsaka Pipeline Ultrasonic Calibration Data - JMP" )} ), Dispatch( {}, "X title", Text. Edit. Box, {Set Text( "Lab Defect Size " )} ), Dispatch({}, "Y title", Text. Edit. Box, {Set Text( "ln(Field Defect Size)" )} ) ) );
/* Box-Cox linearity plot */ R Submit( "[ ## Transformations of predictor variable lnldef = log(ldef) sqrtldef = sqrt(ldef) invldef = 1/ldef ## Box-Cox linearity plot for (i in (0: 100)){ alpha = -2 + 4*i/100 if (alpha != 0){ tx = ((ldef**alpha) - 1)/alpha temp = lm(lnfdef~tx) temps = summary(temp) if(i==0) {rsq = temps$r. squared alp = alpha} else {rsq = rbind(rsq, temps$r. squared) alp = rbind(alp, alpha)} }} rcor = sqrt(rsq) par(mfrow=c(1, 1), cex=1. 25) plot(alp, rcor, type="l", xlab="Alpha", ylab="Correlation", main="Box-Cox Linearity Plot ln(Field) Lab", ylim=c(. 6, 1), col="blue") #creaate Correlation and Alpha vectors into BCP data frame Corr <- as. vector(rcor) Alpha <- as. vector(alp) BCP <- data. frame(Corr, Alpha) ]" ); RBCP = R Get(BCP); RBCP << New. Data. View << Set Name("R Data Frame of Alpha-Correlation Table") ;
® Why JMP and R ? “JMP is a wonderful complement to R. The integration with R is surfaced with several new JSL commands that allow you to connect to an install of R on your desktop, send data to and from R, and submit R routines available through the R packages. JMP dialogs can easily be built for parameter input to R as a front-end, and more significantly, JMP’s interactive and dynamic statistical platforms and graphics make for a perfect back-end to R functions. ” --Kelci Miclaus, JMP® Life Sciences R&D Manager, https: //community. jmp. com/t 5/JMP-Blog/JMP-Into-R/ba-p/29852
References 1. NIST/SEMATECH e-Handbook of Statistical Methods (2012), “ 4. 6. 2. Alaska Pipeline” , http: //www. itl. nist. gov/div 898/handbook/pmd/section 6/pmd 62. htm (accessed 08/24/2017). 2. Miclaus, K. (2010), “JMP into R!, ” https: //community. jmp. com/t 5/JMP-Blog/JMPInto-R/ba-p/29852 (accessed 08/24/2017). 3. Miclaus, K. ( 2010 ), “On-Demand Webcast: JMP and R Integration, ” https: //www. jmp. com/en_gb/events/ondemand/mastering-jmp/jmp-and-rintegration. html (accessed 08/24/2017). 4. Stephan, D. (2017), “Experiences with and Recommendations for using R for Statistics/Analytics Instruction: Using JMP with R, ” http: //www. people. vcu. edu/~randrews/DASI/SEDSI 2017/Stephan_DASI_SEDSI 2017. pptx (accessed 08/24/2017). 5. Gong, J. (2016), “Getting Started with the JMP to R Interface, ” https: //community. jmp. com/t 5/JMPer-Cable/Getting-started-with-the-JMP-to-RInterface/ba-p/43920 (accessed 09/12/2017).
Disclaimer • The views expressed in this presentation are those of the presenter and do not necessarily represent the views of the Social Security Administration(SSA) or SAS Institute, Inc.
Questions? Contact: Melvin. Alexander@ssa. gov Melvin. alexander@Verizon. net JMP, SAS, and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand product names are trademarks of their respective companies.
Acknowledgements (Many Thanks to the following for their help with this presentation and support) JMP® Division of SAS® (Cary, NC) • Anna-Christina De La Iglesia • Gail Massari • Robin Moran • Robyn Godfrey • Tom Donnelly US Bureau of Labor Statistics (Washington, DC) • Josh Klick
- Linear pipeline processors in computer architecture
- Pipeline vs superscalar
- Jmp application builder
- Three dimensions of corporate strategy
- Make or buy continuum
- Integration
- Integration using tables and computer algebra systems
- Information oriented application integration
- Information-oriented application integration
- Presentation integration model
- Information oriented approach
- Application integration architecture diagram
- Steps for application integration
- Disadvantages of enterprise application integration
- Cylindrical shells method formula
- Enterprise architecture integration patterns
- Integration by substitution formula
- Automate java application
- Ebp and esp
- Dr samira khan
- Jmp neural network