SlideShare a Scribd company logo
Boot Camp R Fall 2013
PT651 Lab Component
Slides by Sherri Verdugo
•  Brief definition of statistics: The subject of
statistics deals with techniques for collecting,
analyzing, and drawing conclusions from data. In
science, or any subject, even psychology, you
must know how to read the literature or how to
interpret data. Statistics is your key, to knowing
when you are given false data--or, for example, if
that new medication really works. Definition is from
Statistical Methods, Eighth Edition by George
W. Snedecor and William G. Cochran.
Statistics
Brief description.
R Boot Camp and Descriptive Information
Agenda
Introduction to the Lab Component
Wrap Up
R: The basics and Rstudio; The basics
Descriptive Statistics & R
Revisiting the Blog and Installation
Parameters, Statistics oh my….the magic behind the curtain
Measures of Variability & R
✓
1
2
3
4
5
6
7
Installing	
  on	
  your	
  desktop	
  means	
  that	
  the	
  	
  
environment	
  is	
  local	
  on	
  your	
  machine!	
  
Installing	
  on	
  the	
  Cloud	
  means	
  you	
  are	
  
portable	
  and	
  accessible!	
  
• The Blog
Installation tips
- http://g2research.blogspot.com/2013_08_01_archive.html
ü PC, Mac, Unix, etc.
• Desktop or Cloud
R & R Studio
-R on the Desktop
ü R on the Cloud
The Blog and Installation of R
Revisiting the Past
Desktop versus the cloud
R
R is available locally on your computer and
depends on the size of your computer!
R is available on the internet! Fast!
Rstudio and R are located on the cloud.
Cloud
R is located on local machine. Drawbacks:
only in one environment.
Desktop
21
A sample represents a population. Dependent Variables are cheaper and easier to change J
The magic behind the curtain.
Parameters, Statistics, oh my!
1
Population characteristics.
Parameters
Measures of sample data.
Statistics
3
Rank order of data values for a
variable.
f = Frequency Distribution
Caveat:
Class: grouping of scores w/ unique range
Independent Variables: costly or nearly
impossible to change. I.E.
Dependent Variables: outcome variables.
Mutually Exclusive: no overlap in classes
Mutually Exhaustive: each score fits into a
class
2
Descriptive Statistics: ways to represent data using characterization of
central tendency, shape and variability in the data.
Three Measures of Central Tendency
Measures of Central Tendency:
central value or a typical value for a probability distribution
M3
Which score changes the most when you change the
scores in the data?
Frequencies tell a story as well!
3
The most frequent score of the sequence.
Mode
The average of all scores. Is the sample mean and µ is the population mean.
Mean
1
The middle number in a sequence. Place the numbers in order. For N=odd number then this is the exact
mid point. For N=even number add the two middle numbers together and divide by two.
Median
2
X
X =
x1 + x2 +...+ xn
n
µx = ∑ xP(x)
Variability = dispersion of scores.
Adding the deviations results in zero? That’s not what I need. NEW CONCEPT: Sum of Squares (SS).
Percentiles = the grouping of the scores totaling 100%. What percentile is a score in the data set?
Quartiles: Q1=25%, Q2=50%, Q3=75%, Q4=100%
Standard Deviation = how much variation from the mean or what we expect the value to be.
Range = difference between highest and lowest scores.
Variance = how far a set of numbers are “dispersed” or spread out.
Coefficient of Variation = unitized risk expressed as a ratio.
Do you see any patterns?
Name five measures of variability
Variability
1
2
3
4
5
6
7
sx =
(xi − x)2
i=1
n
∑
n −1
sx
2
=
(xi − x)2
i=1
n
∑
n −1
cv =
σ
µ
SS = (x − x)2
∑
Range = Xhighscore − Xlowestscore
cv =
σ
µ
*100
Tip: Remember help() and google/google scholar < This is the command prompt
Examples in R using the Cloud or Desktop
•  How can we find the descriptive statistics
in R?
•  Look at R scripts for: 1) mean, 2) median,
3) mode, 4) range, 5) percentiles, 6)
variance, 7) standard deviation, and 8)
coefficient of variation
•  Class Exercise: 1_descriptives_general.R
Descriptives & R Continued
•  #Descriptive Statistics: General Entry Level Exercise
•  2+2;f=2+2;f #R is a calculator and you can store an answer:
•  a=4;a; c = a*2; c#Solve an equation and store variables
•  fun1=((a+c+2)/2);fun1#Result is 7 (4+8+2)=14 and this is 14/2 = 7
•  #Step 1: generate a few random numbers to look at
•  rnorm(10, mean=1.2, sd=3.4);s=rnorm(10, mean=1.2, sd=3.4);s
•  me=mean(s); me #Mean
•  med=median(s);med #Median
•  table(s);names(sort(-table(s)))[1]#Mode. Not interesting because we don't have any duplicates
•  ra=range(s);ra#range low and high scores
•  mran=max(s);mran;miran=min(s);miran
•  ran=mran-miran;ran#we are running the range from the extremes of the data (hi and lo)
•  qua=quantile(s);qua#quantiles
•  per=quantile(s, c(.32, .57, .98));per#percentiles
•  varia=var(s);varia#variance
•  stds=sd(s);stds#standard deviation
•  stdsc=sqrt(varia);stdsc#double check the std. deviation :)
•  coefs=((stds/me)*100);coefs# sanity check
•  library(raster);cv(s, na.rm=TRUE); #double check with a package.
Descriptive Statistics & R
An Example Script.
Can we normalize scores? Of course we can.
Descriptive Statistics and R
Normal…we want normal for now J Work through the tutorial J
tYes!
1) Samples from a normal
distribution = distribution of
sample means are normal.
2)The mean of the distribution
of sample means = the mean
of the "parent population," the
population from which the
samples are drawn.
3)The higher the sample size
that is drawn, the "narrower"
will be the spread of the
distribution of sample means.
Can we do this in R?
1
Central Limit Theorem
This is the point where you
should see the pattern
between the previous slides
and the new concept of the
CLT. If you feel like it
doesn’t make sense, that is
normal (Yes, I like that word
a lot!)…. However, you can
use this to work through
statistical problems….and
solve complex problems
with relative ease.
Parts of the puzzle have
been given to you.
Sanity Check!
Distribution of many many
trials is normal….even if the
distribution of each trial is
not normal!
http://www.learner.org/
courses/mathilluminated/
units/7/textbook/06.php
Why is this important?
You can work with the law
of large numbers…
Approximations.
32
It might not be normal from the population. It
might however be normal using the Central Limit
Theorem and that means that 68.26% will fall ± 1
s.d. from the mean.
Standard scores (i.e. z-scores) represent scores
distances from the mean. When the mean and
standard deviation are known….you can have a
z-score attached to it. Think IQ tests, SAT, GRE,
MCAT…etc.
To solve any mystery…you are looking for
patterns. Statistics is a tool that gives you the
ability to look for a pattern in a sample that
represents a portion of the population.
Dispersions of the scores
Measures of Variability & R
2
Patterns.
Can we
Standardize?
Is the Population
Normal???
Looking at Real Data that is “Clean”
Measures of Variability & R
Nothing is impossible with R. If you can’t figure it out…think logically. What is it that you want to do and then readdress
the steps that you have taken so far.
• Clean Data
Has no missing values
-Homework Examples
ü Extremely rare in the real world….
• Real Data
Has missing values
-Can be handled by R
ü Big steps involved in cleaning the data set….
Statistics…your guide to the universe
Every Number tells a story
Clean Data
Collect Data
Design a Study.
Analyze Data
Present Data
Conclusions J
Your own sub headline
Wrap Up
3
These have to be loaded before you use them. If you have to use them….make sure you comment on
them in the code so that you can use them again later.
Library or Packages
R Packages have templates ready for you to learn with…some packages are better than others.
Templates
1
Present the descriptive information for the data set. This is key when you are presenting inferential
statistics in a journal, report, homework, or even understanding the data you are reading about.
Always…Always…Always
2
Have productivity anywhere you have internet.
Taking it to the Cloud
When you are in a clinical setting…time is of the
essence. You are dealing with patients and the
information you present must be accurate.
Population
Sample
Information
Patient
Information
THANK YOU!
That wasn’t so hard J Remember you are now
programming! Who needs Excel or SPSS now?
Free is sometimes better in more ways than one!

More Related Content

PDF
Lecture 3b: Decision Trees (1 part)
PPT
Machine Learning: Foundations Course Number 0368403401
PDF
Module 5: Decision Trees
PDF
Machine Learning - Decision Trees
PDF
Lecture 2: Preliminaries (Understanding and Preprocessing data)
PPTX
Decision tree
PPTX
Machine learning session6(decision trees random forrest)
PPT
Decision tree
Lecture 3b: Decision Trees (1 part)
Machine Learning: Foundations Course Number 0368403401
Module 5: Decision Trees
Machine Learning - Decision Trees
Lecture 2: Preliminaries (Understanding and Preprocessing data)
Decision tree
Machine learning session6(decision trees random forrest)
Decision tree

What's hot (19)

PPTX
Introduction to simulating data to improve your research
PPT
MachineLearning.ppt
PPT
Stat11t chapter1
PPT
Stat11t chapter3
PDF
Lecture 8: Machine Learning in Practice (1)
PPT
Stat11t alq chapter03
PDF
L4. Ensembles of Decision Trees
PPT
Stat11t chapter2
PPTX
Decision tree
PDF
Module 3: Linear Regression
PPTX
Data simulation basics
PPTX
Simulating data to gain insights into power and p-hacking
PDF
Module 1.2 data preparation
PDF
Lecture 3: Basic Concepts of Machine Learning - Induction & Evaluation
DOCX
Krupa rm
PDF
Nbe rtopicsandrecomvlecture1
PPT
Machine Learning presentation.
PPTX
Basic statistics 1
PDF
Lecture 9: Machine Learning in Practice (2)
Introduction to simulating data to improve your research
MachineLearning.ppt
Stat11t chapter1
Stat11t chapter3
Lecture 8: Machine Learning in Practice (1)
Stat11t alq chapter03
L4. Ensembles of Decision Trees
Stat11t chapter2
Decision tree
Module 3: Linear Regression
Data simulation basics
Simulating data to gain insights into power and p-hacking
Module 1.2 data preparation
Lecture 3: Basic Concepts of Machine Learning - Induction & Evaluation
Krupa rm
Nbe rtopicsandrecomvlecture1
Machine Learning presentation.
Basic statistics 1
Lecture 9: Machine Learning in Practice (2)
Ad

Viewers also liked (7)

PDF
Apple techmanuals verd
PPT
Leveraging the Cloud for Social Media (IT Track - Social Media Plus May 25th,...
PDF
Socialmediapresentation v2
PDF
PPTX
Indian Premiere League 2015 & Social Media
PDF
Citihub Open Source and Cloud approach to Social Media Listening
PDF
Rstudio in aws 16 9
Apple techmanuals verd
Leveraging the Cloud for Social Media (IT Track - Social Media Plus May 25th,...
Socialmediapresentation v2
Indian Premiere League 2015 & Social Media
Citihub Open Source and Cloud approach to Social Media Listening
Rstudio in aws 16 9
Ad

Similar to Ch17 lab r_verdu103: Entry level statistics exercise (descriptives) (20)

PPTX
UNIT1-2.pptx
PPTX
RESEARCH II grade 8 descriptive and inferential statistics Fourth Quarter 2025
PPTX
Data Science Interview Questions | Data Science Interview Questions And Answe...
PPT
Analysing & interpreting data.ppt
DOCX
Chemistry Lab Manual
PPT
havsHahsSfsAFSsfASFSFSFSfssfAFsfsfastasa
PPTX
Section 6 - Chapter 1 - Introduction to Statistics Part I
PPTX
CABT Math 8 measures of central tendency and dispersion
PPTX
Data in science
PPTX
data
PPTX
DECISION TREE AND PROBABILISTIC MODELS.pptx
PDF
3. measures of central tendency
PPTX
Statistics for IB Biology
PDF
Decision Tree-ID3,C4.5,CART,Regression Tree
PPTX
m2_2_variation_z_scores.pptx
DOCX
Focus on what you learned that made an impression, what may have s.docx
PDF
Data Science & AI Road Map by Python & Computer science tutor in Malaysia
PDF
M08 BiasVarianceTradeoff
PPTX
Lecture 1 Descriptives.pptx
PDF
Learning to learn Model Behavior: How to use "human-in-the-loop" to explain d...
UNIT1-2.pptx
RESEARCH II grade 8 descriptive and inferential statistics Fourth Quarter 2025
Data Science Interview Questions | Data Science Interview Questions And Answe...
Analysing & interpreting data.ppt
Chemistry Lab Manual
havsHahsSfsAFSsfASFSFSFSfssfAFsfsfastasa
Section 6 - Chapter 1 - Introduction to Statistics Part I
CABT Math 8 measures of central tendency and dispersion
Data in science
data
DECISION TREE AND PROBABILISTIC MODELS.pptx
3. measures of central tendency
Statistics for IB Biology
Decision Tree-ID3,C4.5,CART,Regression Tree
m2_2_variation_z_scores.pptx
Focus on what you learned that made an impression, what may have s.docx
Data Science & AI Road Map by Python & Computer science tutor in Malaysia
M08 BiasVarianceTradeoff
Lecture 1 Descriptives.pptx
Learning to learn Model Behavior: How to use "human-in-the-loop" to explain d...

Recently uploaded (20)

PDF
Business Ethics Teaching Materials for college
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
Pre independence Education in Inndia.pdf
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
01-Introduction-to-Information-Management.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Insiders guide to clinical Medicine.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Cell Types and Its function , kingdom of life
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
Cell Structure & Organelles in detailed.
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Business Ethics Teaching Materials for college
human mycosis Human fungal infections are called human mycosis..pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
RMMM.pdf make it easy to upload and study
Pre independence Education in Inndia.pdf
Week 4 Term 3 Study Techniques revisited.pptx
Supply Chain Operations Speaking Notes -ICLT Program
102 student loan defaulters named and shamed – Is someone you know on the list?
01-Introduction-to-Information-Management.pdf
Anesthesia in Laparoscopic Surgery in India
Final Presentation General Medicine 03-08-2024.pptx
Insiders guide to clinical Medicine.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Cell Types and Its function , kingdom of life
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Cell Structure & Organelles in detailed.
Pharmacology of Heart Failure /Pharmacotherapy of CHF

Ch17 lab r_verdu103: Entry level statistics exercise (descriptives)

  • 1. Boot Camp R Fall 2013 PT651 Lab Component Slides by Sherri Verdugo
  • 2. •  Brief definition of statistics: The subject of statistics deals with techniques for collecting, analyzing, and drawing conclusions from data. In science, or any subject, even psychology, you must know how to read the literature or how to interpret data. Statistics is your key, to knowing when you are given false data--or, for example, if that new medication really works. Definition is from Statistical Methods, Eighth Edition by George W. Snedecor and William G. Cochran. Statistics Brief description.
  • 3. R Boot Camp and Descriptive Information Agenda Introduction to the Lab Component Wrap Up R: The basics and Rstudio; The basics Descriptive Statistics & R Revisiting the Blog and Installation Parameters, Statistics oh my….the magic behind the curtain Measures of Variability & R ✓ 1 2 3 4 5 6 7
  • 4. Installing  on  your  desktop  means  that  the     environment  is  local  on  your  machine!   Installing  on  the  Cloud  means  you  are   portable  and  accessible!   • The Blog Installation tips - http://g2research.blogspot.com/2013_08_01_archive.html ü PC, Mac, Unix, etc. • Desktop or Cloud R & R Studio -R on the Desktop ü R on the Cloud The Blog and Installation of R Revisiting the Past
  • 5. Desktop versus the cloud R R is available locally on your computer and depends on the size of your computer! R is available on the internet! Fast! Rstudio and R are located on the cloud. Cloud R is located on local machine. Drawbacks: only in one environment. Desktop 21
  • 6. A sample represents a population. Dependent Variables are cheaper and easier to change J The magic behind the curtain. Parameters, Statistics, oh my! 1 Population characteristics. Parameters Measures of sample data. Statistics 3 Rank order of data values for a variable. f = Frequency Distribution Caveat: Class: grouping of scores w/ unique range Independent Variables: costly or nearly impossible to change. I.E. Dependent Variables: outcome variables. Mutually Exclusive: no overlap in classes Mutually Exhaustive: each score fits into a class 2 Descriptive Statistics: ways to represent data using characterization of central tendency, shape and variability in the data.
  • 7. Three Measures of Central Tendency Measures of Central Tendency: central value or a typical value for a probability distribution M3 Which score changes the most when you change the scores in the data? Frequencies tell a story as well! 3 The most frequent score of the sequence. Mode The average of all scores. Is the sample mean and µ is the population mean. Mean 1 The middle number in a sequence. Place the numbers in order. For N=odd number then this is the exact mid point. For N=even number add the two middle numbers together and divide by two. Median 2 X X = x1 + x2 +...+ xn n µx = ∑ xP(x)
  • 8. Variability = dispersion of scores. Adding the deviations results in zero? That’s not what I need. NEW CONCEPT: Sum of Squares (SS). Percentiles = the grouping of the scores totaling 100%. What percentile is a score in the data set? Quartiles: Q1=25%, Q2=50%, Q3=75%, Q4=100% Standard Deviation = how much variation from the mean or what we expect the value to be. Range = difference between highest and lowest scores. Variance = how far a set of numbers are “dispersed” or spread out. Coefficient of Variation = unitized risk expressed as a ratio. Do you see any patterns? Name five measures of variability Variability 1 2 3 4 5 6 7 sx = (xi − x)2 i=1 n ∑ n −1 sx 2 = (xi − x)2 i=1 n ∑ n −1 cv = σ µ SS = (x − x)2 ∑ Range = Xhighscore − Xlowestscore cv = σ µ *100
  • 9. Tip: Remember help() and google/google scholar < This is the command prompt Examples in R using the Cloud or Desktop •  How can we find the descriptive statistics in R? •  Look at R scripts for: 1) mean, 2) median, 3) mode, 4) range, 5) percentiles, 6) variance, 7) standard deviation, and 8) coefficient of variation •  Class Exercise: 1_descriptives_general.R Descriptives & R Continued
  • 10. •  #Descriptive Statistics: General Entry Level Exercise •  2+2;f=2+2;f #R is a calculator and you can store an answer: •  a=4;a; c = a*2; c#Solve an equation and store variables •  fun1=((a+c+2)/2);fun1#Result is 7 (4+8+2)=14 and this is 14/2 = 7 •  #Step 1: generate a few random numbers to look at •  rnorm(10, mean=1.2, sd=3.4);s=rnorm(10, mean=1.2, sd=3.4);s •  me=mean(s); me #Mean •  med=median(s);med #Median •  table(s);names(sort(-table(s)))[1]#Mode. Not interesting because we don't have any duplicates •  ra=range(s);ra#range low and high scores •  mran=max(s);mran;miran=min(s);miran •  ran=mran-miran;ran#we are running the range from the extremes of the data (hi and lo) •  qua=quantile(s);qua#quantiles •  per=quantile(s, c(.32, .57, .98));per#percentiles •  varia=var(s);varia#variance •  stds=sd(s);stds#standard deviation •  stdsc=sqrt(varia);stdsc#double check the std. deviation :) •  coefs=((stds/me)*100);coefs# sanity check •  library(raster);cv(s, na.rm=TRUE); #double check with a package. Descriptive Statistics & R An Example Script.
  • 11. Can we normalize scores? Of course we can. Descriptive Statistics and R Normal…we want normal for now J Work through the tutorial J tYes! 1) Samples from a normal distribution = distribution of sample means are normal. 2)The mean of the distribution of sample means = the mean of the "parent population," the population from which the samples are drawn. 3)The higher the sample size that is drawn, the "narrower" will be the spread of the distribution of sample means. Can we do this in R? 1 Central Limit Theorem This is the point where you should see the pattern between the previous slides and the new concept of the CLT. If you feel like it doesn’t make sense, that is normal (Yes, I like that word a lot!)…. However, you can use this to work through statistical problems….and solve complex problems with relative ease. Parts of the puzzle have been given to you. Sanity Check! Distribution of many many trials is normal….even if the distribution of each trial is not normal! http://www.learner.org/ courses/mathilluminated/ units/7/textbook/06.php Why is this important? You can work with the law of large numbers… Approximations. 32
  • 12. It might not be normal from the population. It might however be normal using the Central Limit Theorem and that means that 68.26% will fall ± 1 s.d. from the mean. Standard scores (i.e. z-scores) represent scores distances from the mean. When the mean and standard deviation are known….you can have a z-score attached to it. Think IQ tests, SAT, GRE, MCAT…etc. To solve any mystery…you are looking for patterns. Statistics is a tool that gives you the ability to look for a pattern in a sample that represents a portion of the population. Dispersions of the scores Measures of Variability & R 2 Patterns. Can we Standardize? Is the Population Normal???
  • 13. Looking at Real Data that is “Clean” Measures of Variability & R Nothing is impossible with R. If you can’t figure it out…think logically. What is it that you want to do and then readdress the steps that you have taken so far. • Clean Data Has no missing values -Homework Examples ü Extremely rare in the real world…. • Real Data Has missing values -Can be handled by R ü Big steps involved in cleaning the data set….
  • 14. Statistics…your guide to the universe Every Number tells a story Clean Data Collect Data Design a Study. Analyze Data Present Data Conclusions J
  • 15. Your own sub headline Wrap Up 3 These have to be loaded before you use them. If you have to use them….make sure you comment on them in the code so that you can use them again later. Library or Packages R Packages have templates ready for you to learn with…some packages are better than others. Templates 1 Present the descriptive information for the data set. This is key when you are presenting inferential statistics in a journal, report, homework, or even understanding the data you are reading about. Always…Always…Always 2
  • 16. Have productivity anywhere you have internet. Taking it to the Cloud When you are in a clinical setting…time is of the essence. You are dealing with patients and the information you present must be accurate. Population Sample Information Patient Information
  • 17. THANK YOU! That wasn’t so hard J Remember you are now programming! Who needs Excel or SPSS now? Free is sometimes better in more ways than one!