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

eBook
€22.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
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.
Estimated delivery fee Deliver to Luxembourg

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

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 Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Luxembourg

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

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
€18.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
€189.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
€264.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 117.97
Learning Probabilistic Graphical Models in R
€29.99
Big Data Analytics with R
€45.99
Simulation for Data Science with R
€41.99
Total 117.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 the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela