deepsense.aideepsense.ai logo
  • Careers
    • Job offers
    • Summer internship
  • Clients’ stories
  • Services
    • AI software
    • Team augmentation
    • AI advisory
    • Train your team
  • Industries
    • Retail
    • Manufacturing
    • Financial & Insurance
    • IT operations
    • TMT & Other
    • Medical & Beauty
  • Knowledge base
    • Blog
    • R&D hub
  • About us
    • Our story
    • Management
    • Advisory board
    • Press center
  • Contact
  • Menu Menu
R vs SAS vs SPSS

R vs SAS vs SPSS

November 19, 2015/in Data science /by Przemyslaw Biecek

Such titles, in many cases, are just introductions to flam wars. But not on this blog. Today we are going to illustrate some subtle differences among three statistical packages, R/SAS/SPSS. Small differences, but sometimes even a very small difference may have large consequences. So it is worth to know such things.

In statistics it is not that uncommon that different estimators may be used for the same parameter. A typical example is the standard deviation with two widely used estimators (biased/unbiased). But do you know, that for skewness and for kurtosis there are three common estimators? And for quantiles there is even more, namely 9 different estimators?
And the bizarre thing is that for different statistical packages different estimators are selected as the default ones?
Let’s have a more detailed look.
Skewness / kurtosis
To calculate these two statistics in R, one can use functions skewness and kurtosis from the package e1071. Both functions have additional parameter type to select which estimate of skewness / kurtosis should be calculated.
In R the default option is type=3, but in SAS and SPSS by default equivalents of type=2 are calculated.

x = runif(101)
sapply(1:3, skewness, x=x, na.rm=T)
# [1] 0.1245367 0.1264220 0.1226917
sapply(1:3, kurtosis, x=x, na.rm=T)
# [1] -1.116490 -1.111956 -1.153602

Quantiles
In R in order to calculate qunatiles one can use function quantile. It has an additional argument type, which takes values from 1 to 9. Each option is a different estimator for quantiles. In R by default the definition 7 is used. But for SAS you shall expect results equivalent to type=3, while for SPSS results equivalent with type=6.

sapply(1:9, function(q) quantile(x, 0.01, type=q))
1%         1%         1%         1%         1%         1%         1%         1%         1%
0.02272536 0.02272536 0.01426692 0.01435151 0.01858073 0.01443609 0.02272536 0.01719918 0.01754457

Contrasts
In R, to fit a linear model one usually uses the lm function. The argument contrasts specifies what contrasts are used for qualitative variables. The default contrasts in R are contr.treatment while in SAS you shall expect results equal to these obtained with contr.SAS.

 lm(Sepal.Width~Species, data=iris, contrasts = contr.SAS)$coef
#      (Intercept) Speciesversicolor  Speciesvirginica
#            3.428            -0.658            -0.454
 lm(Sepal.Width~Species, data=iris, contrasts = list(Species=contr.SAS))$coef
#(Intercept)    Species1    Species2
#      2.974       0.454      -0.204

Take home
Even basic statistics like skewness or kurtosis may be calculated in a different way in different statistical packages.
If we are building an analytical solution that is based on R/SAS/SPSS we shall be aware of the possibility that for the same statistic default settings for different packages may lead to different results.

Share this entry
  • Share on Facebook
  • Share on Twitter
  • Share on WhatsApp
  • Share on LinkedIn
  • Share on Reddit
  • Share by Mail
https://deepsense.ai/wp-content/uploads/2019/02/R-vs-SAS-vs-SPSS.jpg 337 1140 Przemyslaw Biecek https://deepsense.ai/wp-content/uploads/2019/04/DS_logo_color.svg Przemyslaw Biecek2015-11-19 23:19:032021-01-05 16:52:17R vs SAS vs SPSS

Start your search here

NEWSLETTER SUBSCRIPTION

    You can modify your privacy settings and unsubscribe from our lists at any time (see our privacy policy).

    This site is protected by reCAPTCHA and the Google privacy policy and terms of service apply.

    THE NEWEST AI MONTHLY DIGEST

    • AI Monthly Digest 20 - TL;DRAI Monthly Digest 20 – TL;DRMay 12, 2020

    CATEGORIES

    • Elasticsearch
    • Computer vision
    • Artificial Intelligence
    • AIOps
    • Big data & Spark
    • Data science
    • Deep learning
    • Machine learning
    • Neptune
    • Reinforcement learning
    • Seahorse
    • Job offer
    • Popular posts
    • AI Monthly Digest
    • Press release

    POPULAR POSTS

    • AI trends for 2021AI trends for 2021January 7, 2021
    • A comprehensive guide to demand forecastingA comprehensive guide to demand forecastingMay 28, 2019
    • What is reinforcement learning? The complete guideWhat is reinforcement learning? deepsense.ai’s complete guideJuly 5, 2018

    Would you like
    to learn more?

    Contact us!
    • deepsense.ai logo white
    • Services
    • Customized AI software
    • Team augmentation
    • AI advisory
    • Knowledge base
    • Blog
    • R&D hub
    • deepsense.ai
    • Careers
    • Summer internship
    • Our story
    • Management
    • Advisory board
    • Press center
    • Support
    • Terms of service
    • Privacy policy
    • Code of ethics
    • Contact us
    • Join our community
    • facebook logo linkedin logo twitter logo
    • © deepsense.ai 2014-
    Scroll to top

    This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.

    OKLearn more

    Cookie and Privacy Settings



    How we use cookies

    We may request cookies to be set on your device. We use cookies to let us know when you visit our websites, how you interact with us, to enrich your user experience, and to customize your relationship with our website.

    Click on the different category headings to find out more. You can also change some of your preferences. Note that blocking some types of cookies may impact your experience on our websites and the services we are able to offer.

    Essential Website Cookies

    These cookies are strictly necessary to provide you with services available through our website and to use some of its features.

    Because these cookies are strictly necessary to deliver the website, refuseing them will have impact how our site functions. You always can block or delete cookies by changing your browser settings and force blocking all cookies on this website. But this will always prompt you to accept/refuse cookies when revisiting our site.

    We fully respect if you want to refuse cookies but to avoid asking you again and again kindly allow us to store a cookie for that. You are free to opt out any time or opt in for other cookies to get a better experience. If you refuse cookies we will remove all set cookies in our domain.

    We provide you with a list of stored cookies on your computer in our domain so you can check what we stored. Due to security reasons we are not able to show or modify cookies from other domains. You can check these in your browser security settings.

    Other external services

    We also use different external services like Google Webfonts, Google Maps, and external Video providers. Since these providers may collect personal data like your IP address we allow you to block them here. Please be aware that this might heavily reduce the functionality and appearance of our site. Changes will take effect once you reload the page.

    Google Webfont Settings:

    Google Map Settings:

    Google reCaptcha Settings:

    Vimeo and Youtube video embeds:

    Privacy Policy

    You can read about our cookies and privacy settings in detail on our Privacy Policy Page.

    Accept settingsHide notification only