Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Simulation for Data Science with R
Simulation for Data Science with R

Simulation for Data Science with R: Effective Data-driven Decision Making

Arrow left icon
Profile Icon Matthias Templ
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2 (5 Ratings)
Paperback Jun 2016 398 pages 1st Edition
eBook
$29.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Matthias Templ
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2 (5 Ratings)
Paperback Jun 2016 398 pages 1st Edition
eBook
$29.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$29.99 $43.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

Simulation for Data Science with R

Chapter 2. R and High-Performance Computing

The software environment R (R Development Core Team, 2015) is nowadays the most commonly used software in the statistical world, and this software is heavily used in this book. The methods described in any of the following chapters are practically applied, and the application of the methods is shown using the statistical environment R. For a book on simulation and data science in R, and to efficiently apply methods, a longer R introduction is needed, especially on features that support efficient calculations.

In this chapter, you will be given a very brief introduction to the functionality of R. This introduction does not replace a general introduction to R but instead shows some useful points, such as introducing modern visualization tools and efficient data manipulation packages. These topics — among others from this chapter — are important for understanding the examples and the R code in the book.

More important than replicating...

The R statistical environment

R was founded by Ross Ihaka and Robert Gentlemen in 1994/1995. It is based on S, a programming language developed by John Chambers (Bell Laboratories), and Scheme. Since 1997, it has been internationally developed and distributed from Vienna over the Comprehensive R Archive Network (CRAN). R is nowadays the most popular and most used software in the statistical world. In addition, R is free and open source (under the GPL2). R is not only a statistical software, it is an environment for interactive computing with data supporting facilities to produce high-quality graphics. The exchange of code with others is easy since everybody can download R. This might also be one reason why modern methods are often exclusively developed in R. R is an object-oriented programming language and has interfaces to many other software products such as C, C++, Java, and interfaces to databases.

Useful information can be found on the following links.

Generic functions, methods, and classes

R has different class systems, the most important ones are S3 and S4 classes. Programming with S3 classes is easy living, it's easier than S4. However, S4 is clean and the use of S4 can make packages very user-friendly.

In any case, in R each object is assigned to a class (the attribute class). Classes allow object-oriented programming and overloading of generic functions. Generic functions produce different output for objects of different classes as soon as methods are written for such classes.

This sounds complex, but with the following example it should get clearer.

As an example of a generic function, we will use the function summary. summary is a generic function used to produce result summaries. The function invokes particular methods that depend on the class of the first argument:

## how often summary is overloaded with methods
## on summary for certain classes
(the number depends on loaded packages)
length(methods(summary))
## [1] 137
class...

Data manipulation in R

For students working with perfectly prepared data from various R packages on relatively small scale problems, data manipulation is not the big issue. However, in the daily practice of a data scientist, most of the time working on data analysis does not involve applying a suitable function to an already perfectly prepared piece of data. The majority of work is done on data manipulation, in order to collect data from several sources, shape the data into a suitable format, and extract the relevant information. Thus, data manipulation is the core work, and data scientists and statisticians should possess strong data manipulation skills.

Whenever you work with data frames, the package dplyr provides user-friendly and computationally efficient code. One package that supports even more efficient data manipulation is the data.table package (Dowle et al., 2015). However, since both packages have their advantages, we report both. Also, data.table works with two dimensional data...

High performance computing

Initially, it is important to measure which lines of code take the most computation time. Here, you should try to solve problems with the processing time of individual calculations by improving the computation time. This can often be done in R by vectorization, or often better by writing individual pieces of code in a compilable language, such as C, C++*, or Fortran**.

In addition, some calculations can be parallelized and accelerated through parallel computing.

Profiling to detect computationally slow functions in code

Take an example where you have written code for your data analysis but it runs (too) slow. However, it is most likely that not all your lines of code are slow and only a few lines need improvement in terms of computational time. In this instance it is very important to know exactly what step in the code takes the most computation time.

The easiest way is to find this out is to work with the R function system.time. We will compare two models:

data(Cars93...

Visualizing information

In many chapters, results are visualized using the graphics capabilities of R. Thus, we will give a very short introduction to the base graphics package, plus a short introduction to the package ggplot2 (Wickham, 2009).

The reader will learn briefly about the graphical system in R, different output formats for traditional graphics system, customization and fine tuning of standard graphics, and the ggplot2 package.

Tip

Other packages such as ggmap, ggvis, lattice, or grid are not touched on here. Interactive graphics are also beyond the scope of this book (Google Charts, rgl, iplots, JavaScript, and R).

The graphics system in R

Many packages include methods to produce plots. Generally, they either use the functionality of the base R package called graphics or the functionality of the package grid.

For example, the package maptools (Bivand and Lewin-Koh, 2015) includes methods for mapping; with this package one can produce maps. It uses the capabilities of the graphics package...

The R statistical environment


R was founded by Ross Ihaka and Robert Gentlemen in 1994/1995. It is based on S, a programming language developed by John Chambers (Bell Laboratories), and Scheme. Since 1997, it has been internationally developed and distributed from Vienna over the Comprehensive R Archive Network (CRAN). R is nowadays the most popular and most used software in the statistical world. In addition, R is free and open source (under the GPL2). R is not only a statistical software, it is an environment for interactive computing with data supporting facilities to produce high-quality graphics. The exchange of code with others is easy since everybody can download R. This might also be one reason why modern methods are often exclusively developed in R. R is an object-oriented programming language and has interfaces to many other software products such as C, C++, Java, and interfaces to databases.

Useful information can be found on the following links.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn five different simulation techniques (Monte Carlo, Discrete Event Simulation, System Dynamics, Agent-Based Modeling, and Resampling) in-depth using real-world case studies
  • A unique book that teaches you the essential and fundamental concepts in statistical modeling and simulation

Description

Data Science with R aims to teach you how to begin performing data science tasks by taking advantage of Rs powerful ecosystem of packages. R being the most widely used programming language when used with data science can be a powerful combination to solve complexities involved with varied data sets in the real world. The book will provide a computational and methodological framework for statistical simulation to the users. Through this book, you will get in grips with the software environment R. After getting to know the background of popular methods in the area of computational statistics, you will see some applications in R to better understand the methods as well as gaining experience of working with real-world data and real-world problems. This book helps uncover the large-scale patterns in complex systems where interdependencies and variation are critical. An effective simulation is driven by data generating processes that accurately reflect real physical populations. You will learn how to plan and structure a simulation project to aid in the decision-making process as well as the presentation of results. By the end of this book, you reader will get in touch with the software environment R. After getting background on popular methods in the area, you will see applications in R to better understand the methods as well as to gain experience when working on real-world data and real-world problems.

Who is this book for?

This book is for users who are familiar with computational methods. If you want to learn about the advanced features of R, including the computer-intense Monte-Carlo methods as well as computational tools for statistical simulation, then this book is for you. Good knowledge of R programming is assumed/required.

What you will learn

  • The book aims to explore advanced R features to simulate data to extract insights from your data.
  • Get to know the advanced features of R including high-performance computing and advanced data manipulation
  • See random number simulation used to simulate distributions, data sets, and populations
  • Simulate close-to-reality populations as the basis for agent-based micro-, model- and design-based simulations
  • Applications to design statistical solutions with R for solving scientific and real world problems
  • Comprehensive coverage of several R statistical packages like boot, simPop, VIM, data.table, dplyr, parallel, StatDA, simecol, simecolModels, deSolve and many more.

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 30, 2016
Length: 398 pages
Edition : 1st
Language : English
ISBN-13 : 9781785881169
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 : Jun 30, 2016
Length: 398 pages
Edition : 1st
Language : English
ISBN-13 : 9781785881169
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 $ 154.97
Learning Probabilistic Graphical Models in R
$38.99
Big Data Analytics with R
$60.99
Simulation for Data Science with R
$54.99
Total $ 154.97 Stars icon

Table of Contents

12 Chapters
1. Introduction Chevron down icon Chevron up icon
2. R and High-Performance Computing Chevron down icon Chevron up icon
3. The Discrepancy between Pencil-Driven Theory and Data-Driven Computational Solutions Chevron down icon Chevron up icon
4. Simulation of Random Numbers Chevron down icon Chevron up icon
5. Monte Carlo Methods for Optimization Problems Chevron down icon Chevron up icon
6. Probability Theory Shown by Simulation Chevron down icon Chevron up icon
7. Resampling Methods Chevron down icon Chevron up icon
8. Applications of Resampling Methods and Monte Carlo Tests Chevron down icon Chevron up icon
9. The EM Algorithm Chevron down icon Chevron up icon
10. Simulation with Complex Data Chevron down icon Chevron up icon
11. System Dynamics and Agent-Based Models Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(5 Ratings)
5 star 80%
4 star 0%
3 star 0%
2 star 0%
1 star 20%
Roland R. Wieser Jul 21, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
For many years I teach students in Statistics (with R).This book is great for self-study. It is unique from content and has a high educational value. I was ever searching for a book that teaches Comutational Statistics (with R) so practical and elementary.You can feel while reading that the author is an experienced educator and scientist. I can fully recommend this book. It should be in the library of any statistician.
Amazon Verified review Amazon
Duncan W. Robinson Sep 06, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Simulation for Data Science with R successfully fills an area of data science that has not traditionally had much coverage other than snippets here in there in broader texts. It shows the reader how to use resampling methods, perform hypothesis testing via bootstrap, demonstrate probability theory using simulation & use Monte Carlo methods for optimization. The theory is fairly concisely explained, the code is plentiful & the potential uses are vast. I highly recommend this book!
Amazon Verified review Amazon
Barbara Szabo Sep 21, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The book has great strategy, because it introduces various topics by humorous examples, which are easy to be understood and than goes to details of the scientific background of computational statistics and simulations.The reader can1) learn more about the advanced features of R (all examples listed in the book, can be downloaded as code files),2) get advices on choosing the right technique applied for simulation, resampling or hypothesis testing,3) easily understand computer-intense methods and tools applied in statistical simulation via memorable examples,4) gain experience when working on real-world dataIf you are still not convinced from the advantages of this book, let me give you more details about it.It covers the main issues you can face with, when you need a computational and methodological framework for statistical simulation. The topics include simulating distributions and datasets, Monte Carlo methods for inference statistics, microsimulation and dynamical systems, furthermore it present solutions using computer-intense approaches.The author gave unique, excellent examples to increase our interest in scientific methods supported by R codes. The system dynamics for instance explained via the love/hate story of Prince Harry and Chelsy Davy, the optimization problem is introduced via the case of an Australian guy who trying to climb to the highest Austrian mountain and so on.Overall this is an excellent book written in a unique style for readers who look for data-driven solutions in simulation with R.
Amazon Verified review Amazon
Amazon Customer Oct 06, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
In my studies of mathematics I have always looked for a book describing the complex field of data simulation understandably and with this book I have finally found what I was hoping for: simulatiion methods are described very neat and as a lot of R code is provided I can easily realise described methods in my job as statistician.
Amazon Verified review Amazon
Steve Miller Jan 12, 2019
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
not a good book. returned.
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.