S Users Guide
Total Page:16
File Type:pdf, Size:1020Kb
the knowledge to act™ ® S-PLUS® 8 for Windows User’s Guide May 2007 Insightful Corporation Seattle, Washington Proprietary Insightful Corporation owns both this software program and its Notice documentation. Both the program and documentation are copyrighted with all rights reserved by Insightful Corporation. The correct bibliographical reference for this document is as follows: S-PLUS® 8 for Windows® User’s Guide, Insightful Corporation, Seattle, WA. Printed in the United States. Copyright Notice Copyright © 1987-2007, Insightful Corporation. All rights reserved. Insightful Corporation 1700 Westlake Avenue N, Suite 500 Seattle, WA 98109-3044 USA Trademarks Insightful, Insightful Corporation, the Insightful logo and tagline "the Knowledge to Act," Insightful Miner, S+, S-PLUS, S+FinMetrics, S+EnvironmentalStats, S+SeqTrial, S+SpatialStats, S+Wavelets, S+ArrayAnalyzer, S-PLUS Graphlets, Graphlet, Trellis, and Trellis Graphics are either trademarks or registered trademarks of Insightful Corporation in the United States and/or other countries. Intel and Pentium are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. Microsoft, Windows, MS-DOS and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Sun, Java and Solaris are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States or other countries. UNIX is a registered trademark of The Open Group. Linux is a registered trademark of Linus Torvalds in the United States and other countries. ii ACKNOWLEDGMENTS S-PLUS would not exist without the pioneering research of the Bell Labs S team at AT&T (now Lucent Technologies): John Chambers, Richard A. Becker (now at AT&T Laboratories), Allan R. Wilks (now at AT&T Laboratories), Duncan Temple Lang, and their colleagues in the statistics research departments at Lucent: William S. Cleveland, Trevor Hastie (now at Stanford University), Linda Clark, Anne Freeny, Eric Grosse, David James, José Pinheiro, Daryl Pregibon, and Ming Shyu. Insightful Corporation thanks the following individuals for their contributions to this and earlier releases of S-PLUS: Douglas M. Bates, Leo Breiman, Dan Carr, Steve Dubnoff, Don Edwards, Jerome Friedman, Kevin Goodman, Perry Haaland, David Hardesty, Frank Harrell, Richard Heiberger, Mia Hubert, Richard Jones, Jennifer Lasecki, W.Q. Meeker, Adrian Raftery, Brian Ripley, Peter Rousseeuw, J.D. Spurrier, Anja Struyf, Terry Therneau, Rob Tibshirani, Katrien Van Driessen, William Venables, and Judy Zeh. iii S-PLUS BOOKS The S-PLUS® documentation includes books to address your focus and knowledge level. Review the following table to help you choose the S-PLUS book that meets your needs. These books are available in PDF format in the following locations: • In your S-PLUS installation directory (SHOME\help on Windows, SHOME/doc on UNIX/Linux). •In the S-PLUS Workbench, from the Help ᭤ S-PLUS Manuals menu item. ® ® • In Microsoft Windows , in the S-PLUS GUI, from the Help ᭤ Online Manuals menu item. S-PLUS documentation. Information you need if you... See the... Are new to the S language and the S-PLUS GUI, Getting Started and you want an introduction to importing data, Guide producing simple graphs, applying statistical models, and viewing data in Microsoft Excel®. Are a system administrator or a licensed user and S-PLUS licensing Web you need guidance licensing your copy of S-PLUS site and/or any S-PLUS module. keys.insightful.com/ Are a new S-PLUS user and need how to use User’s Guide S-PLUS, primarily through the GUI. Are familiar with the S language and S-PLUS, and S-PLUS Workbench you want to use the S-PLUS plug-in, or User’s Guide customization, of the Eclipse Integrated Development Environment (IDE). Have used the S language and S-PLUS, and you Programmer’s Guide want to know how to write, debug, and program functions from the Commands window. iv S-PLUS Books S-PLUS documentation. (Continued) Information you need if you... See the... Are familiar with the S language and S-PLUS, and Application you want to extend its functionality in your own Developer’s Guide application or within S-PLUS. Are familiar with the S language and S-PLUS, and Guide to Graphics you are looking for information about creating or editing graphics, either from a Commands window or the Windows GUI, or using S-PLUS- supported graphics devices. Are familiar with the S language and S-PLUS, and Big Data you want to use the Big Data library to import and User’s Guide manipulate very large data sets. Want to download or create S-PLUS packages for Guide to Packages submission to the Comprehensive S Archival Network (CSAN) site, and need to know the steps. Are looking for categorized information about Function Guide individual S-PLUS functions. If you are familiar with the S language and S-PLUS, Guide to Statistics, and you need a reference for the range of statistical Vol. 1 modelling and analysis techniques in S-PLUS. Volume 1 includes information on specifying models in S-PLUS, on probability, on estimation and inference, on regression and smoothing, and on analysis of variance. If you are familiar with the S language and S-PLUS, Guide to Statistics, and you need a reference for the range of statistical Vol. 2 modelling and analysis techniques in S-PLUS. Volume 2 includes information on multivariate techniques, time series analysis, survival analysis, resampling techniques, and mathematical computing in S-PLUS. v vi CONTENTS S-PLUS Books iv Chapter 1 Introduction 1 Welcome to S-PLUS! 2 Installation 3 Help, Support, and Learning Resources 6 Technical Support 11 Typographic Conventions 14 Chapter 2 Working With Data 15 Introduction 16 Entering, Editing, and Saving Data 18 Viewing and Formatting Data 26 Manipulating Data 39 Libraries Included With S-PLUS 54 Chapter 3 Exploring Data 57 Introduction 58 Visualizing One-Dimensional Data 59 Visualizing Two-Dimensional Data 64 Visualizing Multidimensional Data 91 vii Contents Chapter 4 Creating Plots 121 Introduction 123 Plotting One-Dimensional Data 126 Plotting Two-Dimensional Data 136 Plotting Multidimensional Data 148 Trellis Graphs 163 Chapter 5 Importing and Exporting Data 165 Introduction 166 Supported File Types for Importing and Exporting 167 Importing From and Exporting to Data Files 172 Importing From and Exporting to ODBC Tables 183 Filter Expressions 191 Notes on Importing and Exporting Files of Certain Types 194 Chapter 6 Statistics 199 Introduction 202 Summary Statistics 208 Compare Samples 217 Power and Sample Size 262 Experimental Design 267 Regression 273 Analysis of Variance 303 Mixed Effects 309 Generalized Least Squares 313 Survival 317 Tree 325 Compare Models 329 Cluster Analysis 332 viii Contents Multivariate 343 Quality Control Charts 349 Resample 354 Smoothing 358 Time Series 362 Random Numbers and Distributions 369 References 379 Chapter 7 Working With Objects and Databases 381 Introduction 382 Understanding Object Types and Databases 383 Introducing the Object Explorer 389 Working Wit h Object s 400 Organizing Your Work 410 Chapter 8 Using the Commands Window 417 Introduction 419 Commands Window Basics 420 S-PLUS Language Basics 428 Importing and Editing Data 442 Extracting Subsets of Data 446 Graphics in S-PLUS 450 Statistics 455 Defining Functions 461 Using S-PLUS in Batch Mode 463 Chapter 9 Using the Script and Report Windows 465 Introduction 466 The Script Window 468 Script Window Features 476 ix Contents Time-Saving Tips for Using Scripts 479 The Report Window 484 Printing a Script or Report 486 Chapter 10 Using S-PLUS With Other Applications 487 Using S-PLUS With Microsoft Excel 488 Using S-PLUS With SPSS 507 Using S-PLUS With MathSoft Mathcad 513 Using S-PLUS With Microsoft PowerPoint 520 Chapter 11 Customizing Your S-PLUS Session 525 Introduction 526 Changing Defaults and Settings 527 Customizing Your Session at Startup and Closing 554 Index 559 x INTRODUCTION 1 Welcome to S-PLUS!2 Installation 3 System Requirements 3 Installation Instructions 3 Running S-PLUS 5 Help, Support, and Learning Resources 6 Online Help 6 Online Manuals 9 Tip of the Day 10 S-PLUS on the Web 10 Training Courses 10 Technical Support 11 Books Using S-PLUS 11 Typographic Conventions 14 1 Chapter 1 Introduction WELCOME TO S-PLUS! S-PLUS is based on the latest version of the powerful, object-oriented S language originally developed at Lucent Technologies. S is a rich environment designed for interactive data discovery and is the only language created specifically for data visualization and exploration, statistical modeling, and programming with data. S-PLUS continues to be the premier solution for your data analysis and technical graphing needs. The Microsoft Office-compatible user interface gives you point-and-click access to data manipulation, graphing, and statistics. With S-PLUS, you can program interactively using the S-PLUS programming language. In a typical S-PLUS session, you can: • Import data from virtually any source. • View and edit your data in a convenient Data window. • Create plots with the click of a button. • Control every detail of your graphics and produce stunning, professional-looking output for export to your report document. • Perform statistical analyses from convenient dialogs in the menu system. • Run analysis functions one at a time at the command line or in batches using the Script window. • Create your own functions. • Completely customize your user interface. 2 Installation INSTALLATION To install the software: 1. Insert the S-PLUS CD into your CD-ROM drive. 2. If your operating system supports AutoPlay, installation will proceed automatically. If it does not, run setup.exe in the root directory of the CD-ROM. 3. Follow the on-screen Setup instructions; default settings are recommended. It is a good idea to turn off other applications (in particular, virus checkers) while installing S-PLUS because of known problems with the installation software InstallShield.