Probability Statistics and Data A Fresh Approach Using R 1st Edition Darrin Speegle pdf download
Probability Statistics and Data A Fresh Approach Using R 1st Edition Darrin Speegle pdf download
https://ebookmeta.com/product/probability-statistics-and-data-a-
fresh-approach-using-r-1st-edition-darrin-speegle/
https://ebookmeta.com/product/probability-and-statistics-gtu-
ravish-r-singh/
https://ebookmeta.com/product/probability-and-statistics-for-
engineering-and-the-sciences-with-modeling-using-r-1st-edition-
william-p-fox/
https://ebookmeta.com/product/statistics-for-data-scientists-an-
introduction-to-probability-statistics-and-data-analysis-maurits-
kaptein/
https://ebookmeta.com/product/coding-clean-reliable-and-safe-
rest-apis-with-asp-net-core-8-1st-edition-anthony-giretti/
Come Out Prey Apex Academy Capers 1 1st Edition
Cassandra Featherstone
https://ebookmeta.com/product/come-out-prey-apex-academy-
capers-1-1st-edition-cassandra-featherstone/
https://ebookmeta.com/product/california-studies-in-classical-
antiquity-volume-2/
https://ebookmeta.com/product/mile-high-producer-mile-high-
love-1st-edition-m-k-moore/
https://ebookmeta.com/product/embrace-the-mayhem-1st-edition-
maddison-cole/
https://ebookmeta.com/product/the-wolf-king-siren-publishing-the-
lynn-hagen-manlove-collection-lynn-hagen/
Reassessing Riemann s Paper On the Number of Primes
Less Than a Given Magnitude Walter Dittrich
https://ebookmeta.com/product/reassessing-riemann-s-paper-on-the-
number-of-primes-less-than-a-given-magnitude-walter-dittrich/
Probability, Statistics, and Data
Probability, Statistics, and Data
A Fresh Approach Using R
Darrin Speegle
Bryan Clair
First edition published 2022
by CRC Press
6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487-2742
Reasonable efforts have been made to publish reliable data and information, but the author
and publisher cannot assume responsibility for the validity of all materials or the
consequences of their use. The authors and publishers have attempted to trace the copyright
holders of all material reproduced in this publication and apologize to copyright holders if
permission to publish in this form has not been obtained. If any copyright material has not
been acknowledged please write and let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted,
reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other
means, now known or hereafter invented, including photocopying, microfilming, and
recording, or in any information storage or retrieval system, without written permission
from the publishers.
For permission to photocopy or use material electronically from this work, access
www.copyright.com or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood
Drive, Danvers, MA 01923, 978-750-8400. For works that are not available on CCC please
contact mpkbookspermissions@tandf.co.uk
DOI: 10.1201/9781003004899
Publisher's note: This book has been prepared from camera-ready copy provided by the
authors.
Contents
Preface
Software Installation
1 Data in R
1.1 Arithmetic and variable assignment
1.2 Help
1.3 Vectors
1.4 Indexing vectors
1.5 Data types
1.6 Data frames
1.7 Reading data from files
1.8 Packages
1.9 Errors and warnings
1.10 Useful idioms
Vignette: Data science communities
Vignette: An R Markdown primer
Exercises
2 Probability
2.1 Probability basics
2.2 Simulations
2.3 Conditional probability and independence
2.4 Counting arguments
Vignette: Negative surveys
Exercises
3 Discrete Random Variables
3.1 Probability mass functions
3.2 Expected value
3.3 Binomial and geometric random variables
3.4 Functions of a random variable
3.5 Variance, standard deviation, and independence
3.6 Poisson, negative binomial, and hypergeometric
Vignette: Loops in R
Exercises
4 Continuous Random Variables
4.1 Probability density functions
4.2 Expected value
4.3 Variance and standard deviation
4.4 Normal random variables
4.5 Uniform and exponential random variables
4.6 Summary
Exercises
5 Simulation of Random Variables
5.1 Estimating probabilities
5.2 Estimating discrete distributions
5.3 Estimating continuous distributions
5.4 Central Limit Theorem
5.5 Sampling distributions
5.6 Point estimators
Vignette: Stein's paradox
Exercises
6 Data Manipulation
6.1 Data frames and tibbles
6.2 dplyr verbs
6.3 dplyr pipelines
6.4 The power of dplyr
6.5 Working with character strings
6.6 Structure of data
6.7 The apply family
Vignette: dplyr murder mystery
Vignette: Data and gender
Exercises
10 Tabular Data
10.1 Tables and plots
10.2 Inference on a proportion
10.3 χ2 tests
10.4 χ2 goodness of fit
10.5 χ2 tests on cross tables
10.6 Exact and Monte Carlo methods
Vignette: Tables
Exercises
11 Simple Linear Regression
11.1 Least squares regression line
11.2 Correlation
11.3 Geometry of regression
11.4 Residual analysis
11.5 Inference
11.6 Simulations for simple linear regression
11.7 Cross validation
11.8 Bias-variance tradeoff
Vignette: Simple logistic regression
Exercises
Image Credits
Index
Most chapters in the book contain at least one vignette. These short sections
are not part of the development of the base material. We imagine these
vignettes as starting points for further study for some students, or as
interesting additions to the main material. Examples include chloropleth
maps, data and gender, Stein's paradox, and a treatment of Covid-19 data.
FIGURE 1 Chapter dependencies.
Base R and tidyverse tools are interspersed, depending on which is better
for a particular job, though we don't introduce any tidyverse tools until
Chapter 6. We feel that replicate and the base R plotting tools are
appropriate for doing simulations and creating the types of visualizations
that we need in the first chapters. The dplyr package is used for most data
wrangling beginning in Chapter 6, and ggplot2 is used for most
visualizations beginning in Chapter 7. Other tidyverse tools introduced in
this text, in order of emphasis, are stringr for string manipulation,
tidyr for pivot_longer and pivot_wider, lubridate and
janitor::clean_names.
All data sets for this book are found in freely available R packages. The
bulk of the data sets are in the package associated to this book, fosdata,
and are mostly sourced from open access publications that are linked to in
the help pages of the data. We encourage readers to spend time reading the
publications that were written using the data in the book. We have taken two
approaches to the data from original papers. In some instances, fosdata
provides essentially all of the data from the published paper. This allows
you to explore the data further and think about other visualizations and
analyses that would be useful. It also typically requires some wrangling to
get the data in a format for the analysis. In other instances, we have
simplified the data from the paper quite a bit. In particular, in a few
instances we have modified the data by filtering out observations or
averaging in order to make it reasonable to assume independence. Please
see the links provided in the help pages of fosdata for details.
No book like this would be complete without resources for the student who
wishes to learn more. Here are some suggestions for further study that the
authors have enjoyed:
ggplot2, by Hadley Wickham, gives a nice overview of the capabilities
of the ggplot2 package. Students interested in data visualization
would find this book interesting.
Advanced R, by Hadley Wickham, provides much more information on
R than what we cover in this book. Computer Science students might
enjoy reading this book.
The Statistical Sleuth, by Ramsey and Schafer, will help the student
think more like a statistician when dealing with data sets. This book is
on a lower level mathematically.
Modern Applied Statistics with S, by Venables and Ripley, is a book that
covers more advanced statistical topics without much mathematics.
Introductory Statistics with R, by Peter Dalgaard, is a concise
introduction to using R for many types of statistical procedures.
Mathematical Statistics with Applications, by Wackerly, Mendenhall,
and Scheaffer, is a more mathematical (but still only requiring
multivariate calculus and perhaps basic linear algebra) look at the topics
of this book. Students interested in learning how to do the material in
this book by hand without access to a computer may enjoy this book.
Data Feminism, by D'Ignazio and Klein, offers a way of thinking about
data science and data ethics informed by the ideas of intersectional
feminism. About more than just gender, this book investigates the use
and abuse of the power of data science.
This book is copyright 2021, Darrin Speegle and Bryan Clair. Do not
transmit or reuse without express permission.
Software Installation
R is a programming language, distributed as its own software program.
Other documents randomly have
different content
Congress gaiters must be acknowledged, the hoops also, but
perhaps they may all come again; and then some beauty like the
empress of the French may arise to make them beautiful. They were
large! Beside them Queen Elizabeth's farthingale was an insignificant
circumstance. The belle in the fifties lived in an expansive time.
There was still plenty of room in the world. Houses were broad and
low, carriages were broad and low, furniture was massive. Even a
small pier glass was broadened by great scrolls of mahogany.
Drawing-rooms were filled with vast arm-chairs, sofas, and tables.
The legs of pianos were made as massive as possible.
"Yes, Madame! That is the rarest parure I have. There was never
one like it. There will never be another."
"At the Postmaster-General's the regal ball room was lined with
superb mirrors from floor to ceiling. In the drawing-rooms opposite
the host, hostess, and daughter and Miss Nerissa Saunders occupied
the post of receiving.
This last lady, Mrs. Pugh, wife of the Senator from Ohio, was par
excellence the beauty of the day. To see her in this dress was
enough to "bid the rash gazer wipe his eye." Her eyes were large,
dark, and most expressive. Her hair was dark, her coloring vivid.
Mrs. Douglas, Mrs. Pugh, and Kate Chase were the three
unapproached, unapproachable, beauties of the Buchanan
administration. The daughter of Senator Chase was really too young
to go to balls. She was extremely beautiful, "her complexion was
marvellously delicate, her fine features seeming to be cut from fine
bisque, her eyes, bright, soft, sweet, were of exquisite blue, and her
hair a wonderful color like the ripe corn-tassel in full sunlight. Her
teeth were perfect. Poets sang then, and still sing, of the turn of her
beautiful neck and the regal carriage of her head." She was as
intellectual as she was beautiful. From her teens she had been
initiated into political questions for which her genius and her calm,
thoughtful nature eminently fitted her. When she realized that
neither party would nominate her father for President in 1860, she
turned her energetic mind to the formation of plans and intrigues to
obtain for him the nomination of 1868! She failed in that, she failed
in everything, poor girl. She wrecked her life by a marriage with a
wealthy, uncongenial governor of Rhode Island, from whom she fled
with swift feet across the lawn of the beautiful home at Canonchet,
and hand in hand with poverty and sorrow ended her life in
obscurity.
"I consider it very small in St. Paul to think so much about dress
anyway! One would suppose the thorn in his own flesh would have
made him tender toward others; and Timothy must have been a
poor creature to be taken in by 'braided hair,' 'gold and pearls, and
costly array.' Now, of course, we have a few of those things, and like
to wear our hair neatly; but I don't see why they are not suitable for
us so long as we don't live for them, nor seek to entangle Timothy."
"I wouldn't mind St. Simeon," said my irate friend (she had
worked herself up to a pitch of indignation); "probably he was old
and venerable, and to be tolerated; but it hurts me to be preached
to by a young thing like that minister to-day, as if I were a
Babylonish woman! We don't 'walk haughtily with stretched-forth
necks, walking and mincing as we go, making a tinkling with our
feet.' And as to our 'changeable suits of apparel,' and the 'crimping
pins,' do we live for these things? Our maids make a living by taking
care of them while we are at church hoping to hear of something
better than crimping pins."
"But, my dear—"
"But, my dear, I know all about the matter of evening dress. I've
studied it up. It is a time-honored fashion (I can show you all about
it in my new encyclopædia). You remember I let you air your
learning and quote old Tertullian. Did I look bored?"
"Not at all. You may tell me now. You can finish before we get
home."
"Oh, she had her own reasons for disliking to see a suggestive
bare throat! Queen Bess was not conspicuous for purity. Don't
interrupt me—I'll prove everything by the book—lots of good women
have worn low dresses. Madame Recamier was a pretty good
woman, and so were our grandmothers, and so were the ladies of
the Golden Age in Virginia who reared the boys that won our
independence."
There were many brilliant and beautiful women who escaped the
notice of the society newsmonger of the day.
Then there were Mrs. Yulee, wife of the Senator from Florida,
and her sisters, Mrs. Merrick and Mrs. Holt, all three noted for
personal and intellectual charm; and beautiful Mrs. Robert J. Walker,
who was perhaps the first of the coterie to be called to make a
sacrifice for her country, exchanging the brilliant life in Washington
for the hardships of Kansas—"bleeding Kansas," torn with
dissensions among its "squatter sovereigns," and with a climate of
stern severity, where food froze at night and must be broken with a
hatchet for breakfast. Mrs. Walker shrank from the ordeal, for she
was well fitted for gay society; but the President himself visited her
and begged the sacrifice for the good of the country. She went, and
bore her trials. They were only a little in advance of sterner trials
ordained for some of her Washington friends. Nor must we fail to
acknowledge the social influence of Mrs. Jefferson Davis, one of the
most brilliant women of her time—greatly sought by cultivated men
and women.
But the wittiest and brightest of them all was Mrs. Clay, the wife
of the Senator from Alabama. She was extremely clever, the soul of
every company. A costume ball at which she personated Mrs.
Partington is still remembered in Washington. Mrs. Partington's
sayings could not be arranged beforehand and conned for the
occasion. Her malapropos replies must be improvised on the
moment, and must moreover be seasoned with wit to redeem them
from commonplace dulness. Mrs. Clay rose to the occasion, and her
Mrs. Partington became the Mrs. Partington of the future.
For some inexplicable reason the wives of great men are apt to
be quiet and non-committal—little moons revolving around a great
luminary. Moon-like, one side only is turned to the world. How is it
on the other side? We have a glimpse of it over the demi-tasse in
the drawing-room after dinner, or at our informal "at homes" in our
own houses.
The fashion of the low tea-table had just been introduced. One
could have tea, nothing else. One could always find behind the silver
urns "'igh and 'aughty" butlers serving chocolate, wine, and every
conceivable dainty at the houses of the great Senators, Ministers,
and Cabinet officers. Things were much more distingué at this lady's
tea-table. A few early spring flowers, crocuses, hyacinths, or purple
heather, were blooming here and there about the room. Our hostess
was gowned in some white stuff, and there was a bit of classic
suggestion in her attire, in the jewelled girdle, and an order or medal
tucked under a ribbon. A little white-capped maid welcomed and
ushered us, and managed to hover about for all the service we were
likely to require. The impression grew upon me that all this had been
done for me especially, and I found myself thinking how fortunate it
was I had happened to come. That lovely woman would have been
so sorely disappointed had I stayed away!
But presently other guests arrived. They were all foreigners, but
perceiving the American presence they spoke only English. The
hostess put into motion the most musical conversation. How has she
done it? She has made no effort "to entertain." Conversation had
come unbidden. Russian tea? Why, certainly! Do we ever care for
other than Russian tea? She was deliberate. We forgot we were
sorely pressed this day with seventeen names on our list. We gave
ourselves up to the pleasure of observing her.
She lighted her silver lamp; and, although she wished us to see
the great shining samovar which descended to her from her
grandmother, she said it was good, very good indeed, in the camp or
on journeys when one had only charcoal; but here in America the
fairy lamp to light the wax taper and the alcohol burner beneath the
kettle are best. She poured the water, which had bubbled, but not
boiled (boiling water would make the tea flat), over delicious tea,
paused a moment only, then poured the steaming amber upon two
lumps of sugar, two slices of lemon, and one teaspoonful of rum,
and we pronounced it a perfect cup of tea. But our enchantress said
No, that some day ladies will grow tea in their own conservatories,
and then only will it be perfect in this country; for the ocean voyage
spoils the delicacy of the sensitive herb.
She is to make these people happy for the five minutes they are
around her little board. How does it come to pass that these
strangers find a common ground upon which they can hold animated
conversation?
They talked of genius and geniuses,—how they are not created
by opportunity or culture, but are inspired; how that, apart from
their gifts, they are quite like other people, not even cleverer always.
"Yes," said the Greek girl, with an exalted look in her dark eyes,
"they are chosen, like the prophets, to speak great words or
compose immortal music, or build symphonies in stone; and what
they do is outside themselves altogether." "It is literally true," said
the Englishwoman, "that people have 'a gift' apart from their
ordinary selves. Does not George Eliot say that his novels grow in
him like a plant. No amount of work and study can create a genius!"
And then everybody marvels at the wonderful young man (for
nobody knows it is a woman) who has just written "Adam Bede" and
"The Mill on the Floss."
"A few days later I was sitting in my room at the legation, when
I received a visitor—a slender female closely veiled, who said in a
troubled whisper that she had come to claim protection of the
French government. I told her I could not confer with her while she
was disguised, and she slowly raised her hand and held her veil
aside. I never saw a lovelier face.
"She could not have been older than eighteen years. Her
features were delicate, her eyes large and expressive, her brow
shaded by golden-brown hair. She was deathly white. I never saw
such pallor. 'What can I do for you, my child?' I asked. Well, it was a
sad story. Married to a dissipated young fellow, away on her
wedding journey; threatened, and in terror of losing her life. She
wished the protection of the police. She said she should never have
had the courage to ask it alone, but that she knew I had slept near
her at the Maison Dorée. I had heard! I could understand. I was the
American Minister, and I could help.
"Well, I waited long at the office of the préfet. Finally our turn
came. I rose and made my statement. Imagine my feelings when my
fair client threw back her veil, and with a surprised look said:
When the famous Thirty-sixth Congress met for its long session,
December 5, 1859, the whole country was in ferment over the
execution of John Brown. "An indiscreet move in any direction,"
wrote ex-President Tyler from his plantation, "may produce results
deeply to be deplored. I fear the debates in Congress, and above all
the Speaker's election. If excitement prevails in Congress, it will add
fuel to the flame which already burns so terrifically."[5] He, and all
patriots, might well have been afraid of increased excitement. It was
evident from the first hour that the atmosphere was heavily charged.
The House resolved itself into a great debating society, in which the
only questions were: "Is slavery right or wrong? Shall it, or shall it
not, be allowed in the territories?" The foray of the zealot and
fanatic aggravated the fury of the combatants.