Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Mastering Scientific Computing with R
Mastering Scientific Computing with R

Mastering Scientific Computing with R: Employ professional quantitative methods to answer scientific questions with a powerful open source data analysis environment

Arrow left icon
Profile Icon Paul Gerrard
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.6 (7 Ratings)
Paperback Jan 2015 432 pages 1st Edition
eBook
$22.99 $32.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Paul Gerrard
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.6 (7 Ratings)
Paperback Jan 2015 432 pages 1st Edition
eBook
$22.99 $32.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$22.99 $32.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Mastering Scientific Computing with R

Chapter 2. Statistical Methods with R

This chapter will present an overview of how to summarize your data and get useful statistical information for downstream analysis. We will also show you how to plot and get statistical information from probability distributions and how to test the fit of your sample distribution to well-defined probability distributions. We will also go over some of the functions used to perform hypothesis testing including the Student's t-test, Wilcoxon rank-sum test, z-test, chi-squared test, Fisher's exact test, and F-test.

Before we begin, we will load the gene expression profiling data from the E-GEOD-19577 study entitled "MLL partner genes confer distinct biological and clinical signatures of pediatric AML, an AIEOP study" from the ArrayExpress website to use as a sample dataset for some of our examples. For simplicity, we will not go into the details of how the data was generated, except to mention that the study evaluates the expression...

Descriptive statistics

A useful tool to evaluate your data before you begin your analysis is the summary() function, which provides a summary of the non-parametric descriptors of a sample, as follows:

> summary(probeA)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  4.211   4.645   4.774   4.774   4.892   5.231

You can also get a summary for each column of the matrix using the summary() function, as follows:

> summary(MLLpartner.mx) #output truncated
   GSM487973        GSM487972        GSM487971     
 Min.   : 2.112   Min.   : 1.805   Min.   : 1.994  
 1st Qu.: 3.412   1st Qu.: 3.410   1st Qu.: 3.411  
 Median : 4.736   Median : 4.745   Median : 4.731  
 Mean   : 5.342   Mean   : 5.346   Mean   : 5.355  
 3rd Qu.: 6.870   3rd Qu.: 6.851   3rd Qu.: 6.933  
 Max.   :14.449   Max.   :14.453   Max.   :14.406  

We can also get this information by calling the individual functions used to determine these parameters, namely the mean, median, min, max, and quantile functions, as follows:

&gt...

Probability distributions

R makes it very easy to plot and get statistical information on many probability distributions. For those who are not familiar with probability distributions, they are defined as a table or an equation that links each outcome of a statistical experiment with its probability of occurrence. A summary of many common probability distributions available in R is available in the following table:

Probability distribution

R name

Beta

beta

Binomial

binom

Cauchy

cauchy

Chi square

chisq

Exponential

exp

F

f

Gamma

gamma

Geometric

geom

Hypergeometric

hyper

Logistic

logis

Lognormal

lnorm

Negative Binomial

nbinom

Normal

norm

Poisson

pois

Student t

t

Uniform

unif

Tukey

tukey

Weibull

weib

Wilcoxon

wilcox

You can also get this summary in R by entering help("distributions"). For additional probability distributions, and the packages needed to load them, you can consult the CRAN distributions page at http://cran.r-project.org/web/views...

Fitting distributions

Now that we have seen how to plot and gain statistical information from probability distributions, we will show you how to use R to fit your data to theoretical distributions. There are several methods you can use to test whether your sample distribution fits a theoretical distribution. For example, you may want to see if your sample distribution fits a normal distribution using a Quantile-Quantile plot (Q-Q plot). In R, you can use the qqnorm() function to create a Q-Q plot to evaluate the data. R also has a more generic version of this function called qqplot() to create Q-Q plots for any theoretical distribution. To illustrate the use of these functions, let's create a Q-Q plot to test whether the gene expression values of probeA follow a normal or gamma distribution.

First, let's set the plot settings to display two figures in the same layout:

> par(mfrow=c(1,2))

Use qqnorm() to fit the data to a normal distribution:

qqnorm(probeA)

Add the theoretical line...

Hypothesis testing

Often when we analyze data, we would like to know whether the mean of our sample distribution is different from some theoretical value or expected average. Suppose we measured the height of 12 females and wanted to know if the average we calculated from our sample population is significantly different from the theoretical average height of females, which is 171 cm. A simple test we could perform to test this hypothesis would be the Wilcoxon signed-rank test. To do this in R, we will use the wilcox.test() function with the mu argument set to 171:

> female.heights <- c(117, 162, 143, 120, 183, 175, 147, 145, 165, 167, 179, 116)
> mean(females.heights)
[1] 151.5833
> wilcox.test(female.heights, mu=171)
Wilcoxon signed rank test with continuity correction
data:  female.heights
V = 11.5, p-value = 0.0341
alternative hypothesis: true location is not equal to 171
Warning message:
In wilcox.test.default(female.heights, mu = 171) :
  cannot compute exact p-value with...

Summary

In this chapter, we saw how to obtain useful statistical information from sample populations and probability distributions. You should now be able to summarize your data and obtain useful statistical information such as the mean, median, variance, and so on. You should also be able to plot and obtain useful statistics from theoretical probability distributions, fit your sample data to theoretical probability distributions, perform hypothesis testing using parametric and non-parametric statistical tests, and plot and test whether time series data is stationary using statistical tests.

Now that you have a foundation of how to apply statistical methods to your sample datasets, we will be moving on to linear models in the next chapter, where you will find out how to study the relationship between variables.

Left arrow icon Right arrow icon

Description

If you want to learn how to quantitatively answer scientific questions for practical purposes using the powerful R language and the open source R tool ecosystem, this book is ideal for you. It is ideally suited for scientists who understand scientific concepts, know a little R, and want to be able to start applying R to be able to answer empirical scientific questions. Some R exposure is helpful, but not compulsory.

Who is this book for?

If you want to learn how to quantitatively answer scientific questions for practical purposes using the powerful R language and the open source R tool ecosystem, this book is ideal for you. It is ideally suited for scientists who understand scientific concepts, know a little R, and want to be able to start applying R to be able to answer empirical scientific questions. Some R exposure is helpful, but not compulsory.

What you will learn

  • Master data management in R
  • Perform hypothesis tests using both parametric and nonparametric methods
  • Understand how to perform statistical modeling using linear methods
  • Model nonlinear relationships in data with kernel density methods
  • Use matrix operations to improve coding productivity
  • Utilize the observed data to model unobserved variables
  • Deal with missing data using multiple imputations
  • Simplify highdimensional data using principal components, singular value decomposition, and factor analysis

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 31, 2015
Length: 432 pages
Edition : 1st
Language : English
ISBN-13 : 9781783555253
Category :
Languages :
Concepts :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jan 31, 2015
Length: 432 pages
Edition : 1st
Language : English
ISBN-13 : 9781783555253
Category :
Languages :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 164.97
Mastering Scientific Computing with R
$54.99
R for Data Science
$54.99
Mastering Predictive Analytics with R
$54.99
Total $ 164.97 Stars icon
Banner background image

Table of Contents

11 Chapters
1. Programming with R Chevron down icon Chevron up icon
2. Statistical Methods with R Chevron down icon Chevron up icon
3. Linear Models Chevron down icon Chevron up icon
4. Nonlinear Methods Chevron down icon Chevron up icon
5. Linear Algebra Chevron down icon Chevron up icon
6. Principal Component Analysis and the Common Factor Model Chevron down icon Chevron up icon
7. Structural Equation Modeling and Confirmatory Factor Analysis Chevron down icon Chevron up icon
8. Simulations Chevron down icon Chevron up icon
9. Optimization Chevron down icon Chevron up icon
10. Advanced Data Management Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.6
(7 Ratings)
5 star 14.3%
4 star 42.9%
3 star 28.6%
2 star 14.3%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Arnold Salvacion Mar 01, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
High recommended!My review of the book can be found in http://r-nold.blogspot.com/2015/03/book-review-mastering-scientific.html
Amazon Verified review Amazon
Visier68 Feb 28, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
“Mastering Scientific Computing with R” is a comprehensive book that combines an entry-level approach to data analysis with content targeted to experienced users, who are aiming to streamline their workflow.The author starts with an overview of R, explaining data types and other fundamental concepts, which should be sufficient for novice readers to understand how R differs in its coding style from traditional programming languages. On the other hand, the book is intentionally not written as a cookbook for data analysis. Hence, readers will benefit from previous experience with tools like RStudio and IPython, supporting experiments with functions and code snippets from the book for interactive learning.The first part is covering basic stuff like distributions, hypothesis testing, linear plus nonlinear models and PCA. For advanced users, things get more interesting with Structural Equation Modeling (SEM) in chapter 7, where the author provides a brief but good illustration of practical applications with OpenMx. The book includes a well-written chapter on simulation, explaining the powerful features of Monte Carlo method. It is followed by a chapter on optimization, which is equally useful in solving analytical problems.A strength of this book is that it provides in-depth information regarding some more advanced analytical procedures without being limited to specific domains like bioinformatics or econometrics, making it a recommended addition to the analyst’s bookshelf.What I am missing is a part covering practical deployment of the methodology described, especially in terms of reproducible research and scientific publishing. Reproducibility is essential, and R excels here by encouraging users to focus on scripting and automation rather than point-and-click. This is mentioned several times, but deserves more attention given its importance in science.Tools like Markdown and Pandoc support the creation of fully dynamic documents with minimal effort, which has vastly improved streamlining of workflows in scientific publishing. It would be useful to include some examples and references to further reading.While “Mastering Scientific Computing with R” is quite readable for novice users, I would recommend the book to people who are already familiar with basic tools and building blocks of data analysis, aiming to improve their knowledge about algorithms and standard procedures that typically make up a scientific workflow. But the book is also useful for non-scientific applications and the information provided may be easily transferred for exploitation in any specific domain.
Amazon Verified review Amazon
Kongi Feb 27, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
The book is helpful to people who are just learning how to use R for modelling and simulation. It could be considered as an introduction to Scientific Computing using R not Mastering. I recommend topics such as high performance, parallel computation to be added in further editions of the book.Still glad i bought the book because i picked few points from it.
Amazon Verified review Amazon
TCM Feb 28, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
The “mastering series” provides advanced tutorials and this was exactly what I was looking for. This book goes beyond most other books on R and gives insights into topics such as generalized linear models (GLM), principal component analysis (PCA) and Monte Carlo simulations. The introduction of this book is too advanced for R beginners but provides a good repetition of R’s capabilities and strength. For the rest of this book the reader needs a good grasp of R, statistics and mathematics. As such it distinguishes itself from most other book on R I have seen so far and meets my level of expectation. In any case, this book cannot be recommended as an entry level introduction neither to R nor statistics but is very useful for scientist interested in exploring possibilities for sound data analysis.
Amazon Verified review Amazon
Al Feb 18, 2015
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
This book looks more like an overview of a variety of topics than a Mastering book. I wouldn't recommeded for an in depth coverage of the topics it exposes. Although it could be used as a quick guide to implement a variety of scientific methods in R. I purchase it as part of Packt Publishing $5 Christmas bonanza. For that price, you can't go wrong.One thing missing that I would've liked to see covered is reproducible research. I would think any new scientific programming book in R will cover this topic or at least gives examples of reproducible research.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.