|
Following up on Tuesday’s extension command message, today I want to introduce extension commands that connect to various packages in the R statistical system.
R offers a huge collection of statistical algorithms – over 2000 by one count, so it has the potential to supplement the built-in offerings in SPSS Statistics. On the other hand it is a large and difficult system to learn – it helps to have a background in the C language and a lot of time for experimentation – and its behavior is not always as consistent as one might like. R packages are typically limited to data that will fit in memory. R packages, having many authors, will sometimes fail or behave idiosyncratically. To paraphrase the license agreement: That’s life on the edge. Having built a plug-in for R in SPSS 16 and refined it in version 17, we have now started writing SPSS extension commands that tap particular R packages that we think would be of interest to the SPSS audience. These extensions feature - a SPSS Statistics dialog box interface built with the new SPSS Statistics 17 Custom Dialog Builder, - traditional SPSS syntax created using the extension mechanism, - access to the active SPSS dataset using the plug-in apis, - and pivot table and text output in the SPSS Statistics Viewer. Charts, too, in some cases. So for an SPSS Statistics user, there is almost no difference in usage from built-in procedures. As a consumer of R packages, you get most of the benefit of R with none of the pain. These extension commands require SPSS Statistics 17, and they require you to install R version 2.7. (At this writing, R is up to 2.7.2. Be sure to get 2.7.0.) You also need both the Python and R Plug-Ins from SPSS Developer Central (www.spss.com/devcentral <http://www.spss.com/devcentral> ). (The Python plug-in is also on the SPSS Statistics CD.) For any particular extension, you install it from Developer Central and install the corresponding R package from the R site, and you are ready to go. And did I mention that once you have the base SPSS Statistics 17, everything else is free? If you already know something about Python and R, you can build your own extensions, too. All the things you need are or will be shortly on Developer Central. Since this topic came up again recently on the SPSSX-L list, we thought we would start the R extensions parade with the SPSSINC RASCH extension command. The author says, SPSSINC RASCH makes use of the ltm package (http://wiki.r-project.org/rwiki/doku.php?id=packages:cran:ltm <http://wiki.r-project.org/rwiki/doku.php?id=packages:cran:ltm> ) to fit a Rasch Model (http://en.wikipedia.org/wiki/Rasch_model) to the data and return the estimated values of the model parameters. You can also request that the generated R program be saved to an external file for further use. Following up on that last point, sometimes the R package will have options that we have not exposed in the extension command syntax. For most of the R extensions, an R program (BEGIN PROGRAM R) is generated by the extension command and then passed invisibly to an R process for execution. We have made it possible for users to save the generated program as a starting point for accessing other features of the R package that they might want. You still run it from within SPSS Statistics and get your output in the Viewer and/or as SPSS Statistics datasets. SPSSINC RASCH is not yet posted to Developer Central. It will be there soon. One good source for learning about R is the new book, due at Amazon this month, R for SAS and SPSS Users, by Bob Muenchen of the University of Tennessee. Bob will be speaking at SPSS Directions in Las Vegas in November (see www.spss.com). I’ll also be there and will feature a few extension commands in my presentation. Regards, Jon Peck ________________________________ From: Peck, Jon Sent: Tuesday, September 09, 2008 2:57 PM To: [hidden email] Subject: SPSS Statistics 17 Extension Commands Extension commands are a new feature, begun in SPSS 16 and enhanced in SPSS Statistics 17. The extension mechanism allows anyone to design new syntax and provide their own implementation using Python or R programmability. Once installed, extension commands are automatically available in the SPSS Statistics session just as if they were built in. Version 17 adds the Custom Dialog Builder, which allows anyone to create a dialog box interface for an extension command or for standard commands without doing any programming. The extension mechanism and the Custom Dialog Builder make it easy for program authors to create programs for users of traditional syntax or point-and-click fans. Among the improvements to extension commands in 17 is the ability for the command name to have up to three parts. In order to minimize name collisions, we recommend that authors use their organization name or some similar identifier as the first word of the name. Ours will start with SPSSINC. We have written a number of new extension commands, most with dialog boxes, that will be available for Version 17. I will be sending a few notes about these over the next week or two. These packages can be downloaded from SPSS Developer Central (www.spss.com/devcentral <http://www.spss.com/devcentral> ). As usual, these are provided as is under the terms of the standard SPSS Freeware License that you see when you download something. Of course, the Developer Central forums are available for discussions about these. As with other downloads, you have access to the source code. And they are free. Here’s the first: SPSSINC MODIFY TABLES. This command goes beyond TableLooks and takes the pain out of doing custom formatting of pivot tables. It can control column width, font style and color, and background colors at the level of individual rows or columns and even individual cells (not the widths!). You can include expressions such as x < .05 to apply formatting dynamically to cells meeting the criterion. Data cells and labels can be controlled separately. This can be very useful for things like highlighting totals or unusual values or calling out particular rows or columns in a table. There is even a green stripe feature for those nostalgic for the days of line printers (well, actually it’s blue stripes, but that’s easy to change). The package includes a dialog box interface that appears on the Utilities menu after installation. This command requires the Python plug-in (and SPSS Statistics 17), but no Python knowledge is required in order to use it. However, if you know a bit of Python, you can replace complex script-based formatting with small plug-in functions that go beyond what is build into this command by using its custom function facility. Regards, Jon K. Peck SPSS Inc. [hidden email] <mailto:[hidden email]> (ip) phone 312-651-3435 Jon K. Peck SPSS Inc. [hidden email] <mailto:[hidden email]> (ip) phone 312-651-3435 |
| Free forum by Nabble | Edit this page |
