Search topics and sections

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]

Statistical software workflowp = 0.03DataStatisticalsoftwareResultsData handlingAnalysisGraphics
Statistical software takes in a data table and handles, analyzes, and graphs the data. It returns results such as summary tables, test values like p=0.03p = 0.03, and plots.

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.

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]

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]

Requesting an analysis through menus or a script Menus Script Output group outcome Chi-squared test Paste OK load data test outcome by group save results Analysis engine Statistic Value Chi-sq 8.41 p value 0.004 Paste writes the commands Saved script can be rerun and shared
The same chi-squared test (a test that compares observed counts with expected counts) can be requested from a menu dialog or from a script. The Paste button writes the dialog's choices as commands, and both routes send the request to the analysis engine, the part of the program that runs the analysis and produces the output table.

History

Statistical software grew with computers, moving from shared mainframes to personal computers to free programming environments.

Timeline of statistical software, 1960 to 2010Mainframe packagesPersonal computers1960197019801990200020101962 BMD (UCLA)1970 Genstat first version1974 GLIM released1989 JMP (Macintosh)1996 R described byIhaka and Gentleman2000 R officiallylaunched1985 Stata 1.01994 EViews replacesMicroTSP2008 pandasdevelopment begins1976 SAS Institute founded;S planning beginsat Bell Labs1972 Minitab (Penn State)1968 SPSS first version
Statistical software from 1960 to 2010. Packages from the 1960s and 1970s ran on mainframes; from the 1980s, new programs and versions ran on personal computers.

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 SS is the core of the variance. A deviation is the difference between a data value and the mean.[28]

The sample variance is S/(N−1)S/(N-1) or S/NS/N, depending on the use.[28]

The standard two-pass method reads the data twice, once for the mean and once for the deviations:[28]

S=∑i=1N(xi−xˉ)2,xˉ=1N∑i=1NxiS=\sum_{i=1}^{N}(x_i-\bar{x})^2, \qquad \bar{x}=\frac{1}{N}\sum_{i=1}^{N}x_i

Here xix_i are the NN data values and xˉ\bar{x} is their mean. Many textbooks rewrite this as a one-pass formula:[28]

S=∑i=1Nxi2−1N(∑i=1Nxi)2S=\sum_{i=1}^{N}x_i^{2}-\frac{1}{N}\left(\sum_{i=1}^{N}x_i\right)^{2}

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 SS 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 −6,−3,3,6-6, -3, 3, 6, and S=36+9+9+36=90S = 36 + 9 + 9 + 36 = 90.

The one-pass formula instead computes ∑xi2=4,000,000,080,000,000,490\sum x_i^2 = 4{,}000{,}000{,}080{,}000{,}000{,}490 and (∑xi)2/4=4,000,000,080,000,000,400(\sum x_i)^2/4 = 4{,}000{,}000{,}080{,}000{,}000{,}400. 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]

Cancellation in the one-pass variance formulaTextbook one-pass formulaabout 16 digits kept in double precisionsum of x squared =4,000,000,080,000,000,490(sum of x) squared / 4 =4,000,000,080,000,000,400first 17 digits agreethe answer depends on these digitstrue difference = 90rounding error is larger than the differenceTwo-pass formulamean = 1,000,000,010deviations: −6, −3, 3, 6squares: 36, 9, 9, 36S = 90small numbers,no cancellation
With data near 10910^9, the one-pass formula subtracts two 19-digit numbers, ∑x2\sum x^2 and (∑x)2/n(\sum x)^2/n, that agree in their first 17 digits, so double precision loses the answer S=90S = 90. The two-pass formula subtracts the mean first and sums small squared deviations, so nothing cancels.

How bad it can get

Chan, Golub, and LeVeque measured how hard a data set is with a condition number κ\kappa:[28]

κ=1+Nxˉ2S\kappa=\sqrt{1+\frac{N\bar{x}^{2}}{S}}

Always κ≥1\kappa \ge 1. When SS is small and xˉ\bar{x} is not near zero, κ\kappa 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, uu 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 SS
Textbook one-pass Nκ2uN\kappa^{2}u
Two-pass Nu+N2κ2u2Nu + N^{2}\kappa^{2}u^{2}
Updating (one value at a time) NκuN\kappa u

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 κ\kappa.
  • 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]

LRE(x,c)=−log⁡10∣x−c∣∣c∣,c≠0\mathrm{LRE}(x,c)=-\log_{10}\frac{|x-c|}{|c|}, \qquad c\neq 0

Here xx is the program's answer and cc is the certified value; when c=0c = 0, the score is −log⁡10∣x∣-\log_{10}|x|. For example, x=0.01521x = 0.01521 against c=0.01522c = 0.01522 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]

P-values for one 2x2 table under three chi-squared defaults 0 0.1 0.2 0.3 0.4 0.5 p-value 0.308 0.381 0.318 Uncorrected chi-squared default in SAS, Stata; also SPSS Yates-corrected chi-squared default in R; also SPSS Fisher exact test SPSS, SAS
One 2x2 table with 200 observations gives p=0.308p = 0.308 with the uncorrected chi-squared test, p=0.381p = 0.381 with the Yates continuity correction, and p=0.318p = 0.318 with Fisher's exact test. Which value a user sees first depends on each package's default.

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 gam function 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

  1. What is R?, The R Foundation, n.d.
  2. 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.
  3. Linear Least Squares Regression, NIST/SEMATECH e-Handbook of Statistical Methods, National Institute of Standards and Technology, n.d.
  4. On the accuracy of statistical procedures in Microsoft Excel 2007, Computational Statistics & Data Analysis, 2008.
  5. On the Numerical Accuracy of Spreadsheets, Journal of Statistical Software, 2010.
  6. Xact Software for Small Datasets, Cytel, n.d.
  7. About SUDAAN, RTI International, n.d.
  8. About EViews, S&P Global, n.d.
  9. MedCalc Statistical Software, MedCalc Software, n.d.
  10. Terence's Stuff: GLMs and GLIM, Institute of Mathematical Statistics, 2014.
  11. JASP: A Fresh Way to Do Statistics, University of Amsterdam, n.d.
  12. JASP FAQ, University of Amsterdam, n.d.
  13. Data Description, makers of Data Desk, Data Description, n.d.
  14. GAUSS Software, Aptech Systems, n.d.
  15. About pandas, pandas project, n.d.
  16. statsmodels documentation, statsmodels developers, n.d.
  17. Wilfrid J. Dixon, In Memoriam, University of California Academic Senate, n.d.
  18. History of Statistics at UCLA (1939 to 1998), UCLA Statistics and Data Science, n.d.
  19. Norman Nie, Stanford scholar and entrepreneur, dies at 72, Stanford Report, 2015.
  20. SAS History, SAS Institute, n.d.
  21. The evolution of statistical computing: a captivating journey through history, VSNi, 2021.
  22. The Student Edition of MINITAB Statistical Software, Smithsonian National Museum of American History, n.d.
  23. StataCorp LLC, StataCorp, n.d.
  24. S, R, and Data Science, The R Journal, 2020.
  25. John M. Chambers, ACM Software System Award, Association for Computing Machinery, 1998.
  26. R FAQ, The R Project, n.d.
  27. Trends in the Usage of Statistical Software and Their Associated Study Designs in Health Sciences Research: A Bibliometric Analysis, Cureus, 2021.
  28. Algorithms for computing the sample variance: analysis and recommendations, Yale University Department of Computer Science Technical Report 222 (published in The American Statistician), 1983.
  29. Floating-Point Arithmetic: Issues and Limitations, Python Software Foundation, n.d.
  30. Statistical Reference Datasets: Background Information, National Institute of Standards and Technology, 2003.
  31. On the Use of Generalized Additive Models in Time-Series Studies of Air Pollution and Health, American Journal of Epidemiology, 2002.

Figure