Statistical software
Statistical software is computer software for analyzing data with the methods of statistics. A program such as R, for example, combines these parts in one environment:[1]
- data handling
- calculation
- analysis tools
- graphics
- a programming language
The first packages ran on mainframe computers in the 1960s. Today's programs range from point-and-click programs such as SPSS to programming environments such as R.
Studies show that the choice of program, and its default settings, can change the numbers a researcher reports.[2]
What statistical software does
R is a useful example of what a statistical program bundles together.[1]
- Data handling: storing and managing data sets.
- Calculation: operators (symbols such as + and × that act on values) for arrays (ordered collections of values), especially matrices (rectangular grids of values).
- Analysis: models, which are mathematical descriptions of data, both linear and nonlinear. R also offers classical hypothesis tests, time-series analysis, classification (assigning cases to known groups), and clustering (grouping similar cases).
- Graphics: plots for exploring data on screen and for print.
- Programming: a language in which users can define new functions, which are named, reusable pieces of code.
In statistics, "linear" means linear in the model's unknown parameters (the numbers the model estimates from the data). A linear model is not limited to a straight line, so a curve such as a quadratic can still be a linear model.[3]
Accuracy tests for statistical software also check its pseudorandom number generators.[4] These generators drive simulation studies, often called Monte Carlo experiments.[5]
Kinds of statistical software
Statistical programs fall into a few broad groups, though many products mix features from more than one. A command language, mentioned below, is a set of typed instructions used to control a program.
| Kind | How people use it | Examples |
|---|---|---|
| General-purpose packages | Menus and dialog boxes, often with a command language | SPSS, SAS, Stata, Minitab, JMP, Genstat, Statgraphics, JASP, Data Desk |
| Programming environments | Typed code, extended with add-on packages | R, S, S-PLUS, Python with libraries (collections of reusable code), GAUSS |
| Specialized packages | Built for one field or one family of methods | StatXact, SUDAAN, EViews, MedCalc, GLIM |
| Spreadsheets | Cell formulas and add-ins | Microsoft Excel |
Specialized programs
Specialized programs focus on one kind of problem.
- StatXact, from Cytel, focuses on exact tests for small or sparse data sets, meaning tables with many empty or nearly empty cells. It offers more than 160 tests and procedures.[6]
- SUDAAN, from RTI International, analyzes data from complex surveys and studies.[7] It accounts for design features such as clustering, weighting (adjusting how much each observation counts), and stratification (dividing a population into groups before sampling).[7]
- EViews is software for econometric modeling and forecasting. It replaced the older MicroTSP program in 1994.[8]
- MedCalc is aimed at biomedical research.[9] It includes tools for comparing measurement methods and for receiver operating characteristic (ROC) curve analysis, which judges how well a diagnostic test separates two groups.[9]
- GLIM was built to fit generalized linear models.[10]
Other programs
Some programs fill special areas within the broad groups above.
- JASP is a free, open-source program from the University of Amsterdam with a graphical user interface. It offers standard analyses in both classical and Bayesian form, and its analyses run as R code behind the interface.[11][12] Its name honors the Bayesian pioneer Harold Jeffreys.[12]
- Data Desk, from Data Description, was built around exploratory data analysis; its sales have ended.[13]
- GAUSS, from Aptech, is a programming platform marketed for econometric modeling in economics and finance.[14]
Python libraries
Python is a general-purpose language that gains statistical tools through add-on libraries.[15][16]
| Library | What it does | Background |
|---|---|---|
| pandas | Handles data tables | Development began in 2008 at AQR Capital Management; open source by the end of 2009[15] |
| statsmodels | Adds statistical models, tests, and data exploration | Results tested against existing statistical packages; released under the open-source Modified BSD license[16] |
Menus versus code
Programs differ most visibly in how a user asks for an analysis.[2]
- Menus: in programs that rely mainly on a graphical user interface, the user picks options with the mouse.
- Commands: in programs such as Stata and R, the user types commands.
Point-and-click programs such as SPSS and JMP can also produce the command syntax behind each menu choice.[2] Syntax is the exact form of the commands a program accepts.
Saving these commands as a script has a separate benefit. A saved script records every step, so the same analysis can be rerun and checked later.
For reproducibility, Hodges and colleagues argue that researchers should report the software, its version, and the command syntax used.[2]
History
Statistical software grew with computers, moving from shared mainframes to personal computers to free programming environments.
Mainframe packages
The first general packages came from universities and research stations in the 1960s.
- BMD (Biomedical Computer Programs) grew from Wilfrid Dixon's 1960 idea at UCLA of programs controlled by parameters, the settings that tell a general program what to do. It was one of the first general statistical packages and later became BMDP.[17] UCLA's statistics department dates its start to 1962 and calls it the first statistical software system distributed worldwide.[18]
- SPSS (Statistical Package for the Social Sciences) was written by Stanford graduate students Norman Nie and Dale Bent with Stanford alumnus C. Hadlai Hull. They released the first version in 1968 and formed a company in 1975, which IBM later bought for $1.2 billion.[19]
- SAS began in the late 1960s, when eight Southern universities joined to build a package for agricultural data, housed at North Carolina State University. SAS Institute was formed in July 1976 with four employees.[20]
- Genstat development began at Rothamsted in 1968, when John Nelder became head of its statistics department. The first version, written in Fortran, came out in 1970.[21]
- Minitab was introduced in 1972 by Barbara Ryan, Thomas Ryan Jr., and Brian Joiner at Penn State, for students rather than professionals. It was modeled on OMNITAB, a larger program from the National Bureau of Standards.[22]
- GLIM was released two years after Nelder and Wedderburn's 1972 paper on generalized linear models. It came from the Royal Statistical Society's Working Party on Statistical Computing, first chaired by Nelder.[10]
Personal computers
Personal computers brought a second wave of programs in the 1980s.[21] Minitab, Inc. was formed in 1983, and Minitab soon ran on personal computers.[22] Stata 1.0 was released in January 1985.[23]
Other major programs followed on personal computers.[21]
- SAS: personal-computer version around 1985.
- SPSS: personal-computer version around 1985.
- JMP: released in 1989, written from the start for the Macintosh with a strong focus on graphics.
The S language
The S language came from Bell Labs and later became the base of a commercial product.
- Origin (1976): the first planning meetings took place at Bell Labs for an interactive statistics system, one that responds as the user works with it.[24]
- Design goals: its designers, including John Chambers and Rick Becker, wanted interactive analysis plus a programming interface to an existing library of Fortran routines.[24]
- Award (1998): Chambers received the ACM Software System Award for S, cited as having "forever altered how people analyze, visualize, and manipulate data".[25]
- Commercial product: S-PLUS became the main commercial product built on S, and its owners bought the rights to S itself in 2004.[24]
R
Ross Ihaka and Robert Gentleman set out to reproduce S as free software. They described their language, R, in a 1996 paper.[24][26]
The name is partly a play on S and partly the first letter of both authors' first names.[26]
R was officially launched in 2000 and gradually became the main source of new statistical software.[24]
R is distributed under the GNU General Public License. Much of R is itself written in R.[1]
R packages
An R package is a standard bundle of code, data, and documentation, shared through archives such as CRAN.[24]
Chambers calls the package structure perhaps R's most important feature for its contributions to data science.[24]
Use in research
A review of 6,469 health-science articles in PubMed from 1997, 2007, and 2017 counted which programs authors named.[27]
- SPSS was most common overall (52.1%), followed by SAS (12.9%) and Stata (12.6%).
- R rose to third place in 2017, at 11.4%.
- For systematic reviews and meta-analyses (methods that combine results from several studies), Review Manager (43.7%) and Stata (38.3%) led.
Numerical accuracy
A computer stores most numbers with limited precision, meaning it keeps only a fixed number of digits, so every step of a calculation can add a small rounding error. Good statistical software chooses methods that keep these errors small, a property called numerical stability; poor methods can print answers with few or no correct digits.[28][5]
Equal formulas, different answers
The sum of squared deviations is the core of the variance. A deviation is the difference between a data value and the mean.[28]
The sample variance is or , depending on the use.[28]
The standard two-pass method reads the data twice, once for the mean and once for the deviations:[28]
Here are the data values and is their mean. Many textbooks rewrite this as a one-pass formula:[28]
The two formulas are equal in arithmetic without rounding, but the second can be disastrous on a computer. When the variance is small compared with the mean, it subtracts two large, rounded numbers that almost cancel, which wipes out most correct digits. This effect is called catastrophic cancellation, and the computed can even come out negative.[28]
A worked example
Take four values: 1,000,000,004; 1,000,000,007; 1,000,000,013; and 1,000,000,016. Their mean is 1,000,000,010, the deviations are , and .
The one-pass formula instead computes and . Both numbers have 19 digits and agree in the first 17, so the answer of 90 depends only on the last two digits. Standard double-precision floating-point numbers carry 53 binary digits, about 16 decimal digits, so the rounding error is larger than the difference.[29]
How bad it can get
Chan, Golub, and LeVeque measured how hard a data set is with a condition number :[28]
Always . When is small and is not near zero, is about the mean divided by the standard deviation (the square root of the variance, a measure of spread). So data with a large mean and a small spread are hard.[28]
Their error bounds use relative error, the size of the error divided by the true value. In the table, is the machine's rounding unit, the largest relative error made in storing one number, and small constants are dropped.[28]
| Method | Bound on relative error in |
|---|---|
| Textbook one-pass | |
| Two-pass | |
| Updating (one value at a time) |
The authors made specific recommendations.[28]
- When all data fit in memory, use a corrected two-pass method.
- For one-pass work, shift the data by a rough estimate of the mean, then choose an algorithm based on the estimated .
- The textbook formula is safe for small integer data summed in integer arithmetic.
Testing against reference data
The U.S. National Institute of Standards and Technology (NIST) publishes the Statistical Reference Datasets in response to industry concerns about the accuracy of statistical software.[30] The collection covers four areas and ranks each data set as lower, average, or higher difficulty:[30]
- summary statistics;
- linear regression, which fits models that are linear in their unknown parameters;[3]
- nonlinear regression;
- analysis of variance, which compares the means of groups by comparing variation within and between them.
For most of these, NIST computed certified values with 500-digit arithmetic and rounded them to 15 significant digits; for nonlinear regression, to 11.[5] Significant digits are the digits of a number that carry meaning, counted from its first nonzero digit.
Testers score a program by its log relative error (LRE), which roughly counts the correct significant digits:[5]
Here is the program's answer and is the certified value; when , the score is . For example, against gives an LRE of about 3.18, or about three correct digits.[5]
McCullough suggested minimum scores for software:[5]
| Problem type | Minimum correct digits |
|---|---|
| Low-difficulty linear regression | 9 |
| Nonlinear regression | 4 (counted as reasonable) |
NIST warns that passing every data set does not guarantee correct results on a user's own data.[30]
Spreadsheets
Spreadsheets are widely used for statistics. Brian Ripley said in 2002, "Let's not kid ourselves: the most widely used piece of software for statistics is Excel."[5]
Accuracy studies have long found problems with them.
- McCullough and Heiser found that Excel 2007, like earlier versions, failed a standard set of mid-level accuracy tests in three areas.[4] These included statistical distributions (the probability patterns that describe how likely each value of a quantity is) and random number generation.[4]
- A 2010 study of five spreadsheets (Calc, Excel, Gnumeric, NeoOffice, and Oleo) found no safe choice among them. All failed on nonlinear regression, and none was suited to Monte Carlo experiments.[5]
Defaults and reproducibility
Every program makes choices the user may never see, such as which correction to apply or when to stop an iterative fit (a process that repeatedly adjusts a model to improve its fit). Different programs make different default choices, so the same data can give different results.[2]
Same test, different defaults
A 2022 study ran common nonparametric tests on the same data in SPSS, SAS, Stata, and R.[2] For Pearson's chi-squared test on a 2×2 table, the packages handle Yates's continuity correction differently:[2]
| Package | Default for a 2×2 chi-squared test |
|---|---|
| SAS | No correction |
| Stata | No correction |
| R | Yates's correction |
| SPSS | Reports both |
On one sample of 200 observations, the packages reported these p-values:[2]
| Method | p-value | Reported by default in |
|---|---|---|
| Uncorrected chi-squared | 0.308 | SPSS, SAS, Stata |
| Yates-corrected chi-squared | 0.381 | SPSS, R |
| Fisher's exact test | 0.318 | SPSS, SAS |
Across the study's three real samples and 30 simulated data sets, the gap between corrected and uncorrected p-values ranged from 0.005 to 0.162, mostly depending on sample size.[2]
The packages also differ on the Mann-Whitney U test. They define its statistic W differently, and some apply a continuity correction by default:[2]
| Package | W is the rank sum of | Continuity correction by default |
|---|---|---|
| Stata | First group | No |
| R | First group | Yes |
| SPSS | Second group | No |
| SAS | Smaller group (second group if sizes are equal) | Yes |
As a result, SPSS gave a different W and a z-statistic with the opposite sign in all three samples. SAS did the same in the large and small samples.[2] A z-statistic measures how far a result lies from the value expected under no effect, in units of standard deviation.
The continuity correction had a separate effect. It made SAS and R p-values larger by 0.001 to 0.002 in the medium and small samples.[2]
The authors count software choice among the researcher degrees of freedom that can affect results.[2]
When defaults go wrong
A 2002 study showed that default settings can bias published science.[31]
- The problem: the
gamfunction in S-Plus 3.4 fits a generalized additive model, which uses flexible curves to adjust for other factors. Under its default settings, its iterative fit could stop before settling on the correct answer, giving biased estimates. This happened when the estimated effects were small and the model used at least two such curves for other factors.[31] - The reanalysis: the authors reanalyzed a major U.S. study of air pollution and death rates. With the default settings, the combined (pooled) estimates were biased upward.[31]
- Stricter settings: the results were close to those from a Poisson regression, a regression method for count data. That model adjusted for the other factors with curves of a set mathematical form, rather than flexible curves shaped by the data.[31]
Good practice
The 2022 comparison closed with practical advice for users.[2]
- Read the documentation to learn which algorithm and corrections a procedure applies.
- Check important results in a second package, or by hand calculation.
- Report the software, its version, and the command syntax used.
- Share data and scripts so others can rerun the analysis.
References
- What is R?, The R Foundation, n.d.
- Researcher degrees of freedom in statistical software contribute to unreliable results: A comparison of nonparametric analyses conducted in SPSS, SAS, Stata, and R, Behavior Research Methods, 2022.
- Linear Least Squares Regression, NIST/SEMATECH e-Handbook of Statistical Methods, National Institute of Standards and Technology, n.d.
- On the accuracy of statistical procedures in Microsoft Excel 2007, Computational Statistics & Data Analysis, 2008.
- On the Numerical Accuracy of Spreadsheets, Journal of Statistical Software, 2010.
- Xact Software for Small Datasets, Cytel, n.d.
- About SUDAAN, RTI International, n.d.
- About EViews, S&P Global, n.d.
- MedCalc Statistical Software, MedCalc Software, n.d.
- Terence's Stuff: GLMs and GLIM, Institute of Mathematical Statistics, 2014.
- JASP: A Fresh Way to Do Statistics, University of Amsterdam, n.d.
- JASP FAQ, University of Amsterdam, n.d.
- Data Description, makers of Data Desk, Data Description, n.d.
- GAUSS Software, Aptech Systems, n.d.
- About pandas, pandas project, n.d.
- statsmodels documentation, statsmodels developers, n.d.
- Wilfrid J. Dixon, In Memoriam, University of California Academic Senate, n.d.
- History of Statistics at UCLA (1939 to 1998), UCLA Statistics and Data Science, n.d.
- Norman Nie, Stanford scholar and entrepreneur, dies at 72, Stanford Report, 2015.
- SAS History, SAS Institute, n.d.
- The evolution of statistical computing: a captivating journey through history, VSNi, 2021.
- The Student Edition of MINITAB Statistical Software, Smithsonian National Museum of American History, n.d.
- StataCorp LLC, StataCorp, n.d.
- S, R, and Data Science, The R Journal, 2020.
- John M. Chambers, ACM Software System Award, Association for Computing Machinery, 1998.
- R FAQ, The R Project, n.d.
- Trends in the Usage of Statistical Software and Their Associated Study Designs in Health Sciences Research: A Bibliometric Analysis, Cureus, 2021.
- Algorithms for computing the sample variance: analysis and recommendations, Yale University Department of Computer Science Technical Report 222 (published in The American Statistician), 1983.
- Floating-Point Arithmetic: Issues and Limitations, Python Software Foundation, n.d.
- Statistical Reference Datasets: Background Information, National Institute of Standards and Technology, 2003.
- On the Use of Generalized Additive Models in Time-Series Studies of Air Pollution and Health, American Journal of Epidemiology, 2002.
