Variables. Exploratory Data Analysis



Similar documents
Exploratory data analysis (Chapter 2) Fall 2011

Exercise 1.12 (Pg )

Lecture 1: Review and Exploratory Data Analysis (EDA)

BNG 202 Biomechanics Lab. Descriptive statistics and probability distributions I

Chapter 1: Looking at Data Section 1.1: Displaying Distributions with Graphs

Northumberland Knowledge

Exploratory Data Analysis

3: Summary Statistics

STATS8: Introduction to Biostatistics. Data Exploration. Babak Shahbaba Department of Statistics, UCI

Lecture 2: Descriptive Statistics and Exploratory Data Analysis

Classify the data as either discrete or continuous. 2) An athlete runs 100 meters in 10.5 seconds. 2) A) Discrete B) Continuous

Introduction to Environmental Statistics. The Big Picture. Populations and Samples. Sample Data. Examples of sample data

Statistics Chapter 2

AP * Statistics Review. Descriptive Statistics

1.3 Measuring Center & Spread, The Five Number Summary & Boxplots. Describing Quantitative Data with Numbers

Center: Finding the Median. Median. Spread: Home on the Range. Center: Finding the Median (cont.)

Descriptive statistics Statistical inference statistical inference, statistical induction and inferential statistics

Diagrams and Graphs of Statistical Data

Week 1. Exploratory Data Analysis

The right edge of the box is the third quartile, Q 3, which is the median of the data values above the median. Maximum Median

Exploratory Data Analysis. Psychology 3256

Summarizing and Displaying Categorical Data

Descriptive Statistics

Chapter 1: Exploring Data

Topic 9 ~ Measures of Spread

Describing, Exploring, and Comparing Data

How To Write A Data Analysis

Tutorial 3: Graphics and Exploratory Data Analysis in R Jason Pienaar and Tom Miller

Using SPSS, Chapter 2: Descriptive Statistics

+ Chapter 1 Exploring Data

Why Taking This Course? Course Introduction, Descriptive Statistics and Data Visualization. Learning Goals. GENOME 560, Spring 2012

The Big Picture. Describing Data: Categorical and Quantitative Variables Population. Descriptive Statistics. Community Coalitions (n = 175)

BASIC STATISTICAL METHODS FOR GENOMIC DATA ANALYSIS

a. mean b. interquartile range c. range d. median

HISTOGRAMS, CUMULATIVE FREQUENCY AND BOX PLOTS

Mind on Statistics. Chapter 2

STAT355 - Probability & Statistics

MBA 611 STATISTICS AND QUANTITATIVE METHODS

Introduction to Statistics for Psychology. Quantitative Methods for Human Sciences

DATA INTERPRETATION AND STATISTICS

Descriptive Statistics

Data Exploration Data Visualization

Basics of Statistics

AP Statistics Solutions to Packet 2

The Normal Distribution

6.4 Normal Distribution

THE BINOMIAL DISTRIBUTION & PROBABILITY

First Midterm Exam (MATH1070 Spring 2012)

Foundation of Quantitative Data Analysis

Descriptive Statistics. Purpose of descriptive statistics Frequency distributions Measures of central tendency Measures of dispersion

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

consider the number of math classes taken by math 150 students. how can we represent the results in one number?

Probability and Statistics Vocabulary List (Definitions for Middle School Teachers)

Lecture 2. Summarizing the Sample

Geostatistics Exploratory Analysis

Summary of Formulas and Concepts. Descriptive Statistics (Ch. 1-4)

5/31/ Normal Distributions. Normal Distributions. Chapter 6. Distribution. The Normal Distribution. Outline. Objectives.

determining relationships among the explanatory variables, and

Shape of Data Distributions

EXAM #1 (Example) Instructor: Ela Jackiewicz. Relax and good luck!

Module 2: Introduction to Quantitative Data Analysis

2 Describing, Exploring, and

Measurement & Data Analysis. On the importance of math & measurement. Steps Involved in Doing Scientific Research. Measurement

Pie Charts. proportion of ice-cream flavors sold annually by a given brand. AMS-5: Statistics. Cherry. Cherry. Blueberry. Blueberry. Apple.

AMS 7L LAB #2 Spring, Exploratory Data Analysis

Chapter 2: Frequency Distributions and Graphs

Interpreting Data in Normal Distributions

6 3 The Standard Normal Distribution

List of Examples. Examples 319

Ch. 3.1 # 3, 4, 7, 30, 31, 32

Exploratory Data Analysis

Data Handling and Probability (Grades 10, 11 and 12)

A Correlation of. to the. South Carolina Data Analysis and Probability Standards

IBM SPSS Statistics for Beginners for Windows

Common Tools for Displaying and Communicating Data for Process Improvement

2. Here is a small part of a data set that describes the fuel economy (in miles per gallon) of 2006 model motor vehicles.

4.1 Exploratory Analysis: Once the data is collected and entered, the first question is: "What do the data look like?"

Density Curve. A density curve is the graph of a continuous probability distribution. It must satisfy the following properties:

GeoGebra Statistics and Probability

Intro to Statistics 8 Curriculum

Bar Graphs and Dot Plots

Drawing a histogram using Excel

STT315 Chapter 4 Random Variables & Probability Distributions KM. Chapter 4.5, 6, 8 Probability Distributions for Continuous Random Variables

How To Understand The Scientific Theory Of Evolution

MEASURES OF VARIATION

Box-and-Whisker Plots

UNIVERSITY OF TORONTO SCARBOROUGH Department of Computer and Mathematical Sciences Midterm Test March 2014

SPSS Manual for Introductory Applied Statistics: A Variable Approach

UW-Madison All Degrees Awarded (Source:

Key Concept. Density Curve

Chapter 3. The Normal Distribution

Box-and-Whisker Plots

Describing and presenting data

Dongfeng Li. Autumn 2010

Demographics of Atlanta, Georgia:

Visualizing Data. Contents. 1 Visualizing Data. Anthony Tanbakuchi Department of Mathematics Pima Community College. Introductory Statistics Lectures

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Transcription:

Exploratory Data Analysis Exploratory Data Analysis involves both graphical displays of data and numerical summaries of data. A common situation is for a data set to be represented as a matrix. There is a row for each unit and a column for each variable. A unit is an object that can be measured, such as a person, or a thing. A variable is a characteristic of a unit that can be assigned a number or a category. In the data set I collected from the survey of students in the class, each student who responded to the survey is a unit. Variables include sex, major, year in school, miles from home, height, and blood type. Variables We can also make a categorical variable from a continuous variable by dividing the range of the variable into classes (So, for example, height could be categorized as short, average, or tall). Identifying the types of variables can be important because some methods of statistical analysis are appropriate only for a specific type of variable. Statistics 371, Fall 2003 1 Statistics 371, Fall 2003 2 Variables Statistics 371, Fall 2003 Exploratory Data Analysis Bret Larget Department of Statistics University of Wisconsin - Madison September 8, 2003 Variables are either quantitative or categorical. In a categorical variable, the measurement for each unit is a category. For example, for the data I collected in the course survey, the variables blood type and sex are categorical. The variable year in school is an example of an ordinal categorical variable, because there is a meaningful ordering of the levels of the variable. Quantitative variables record a number for each unit. The variable height is an example of a continuous variable because it could take on a continuum of possible values. The variable number of sisters is discrete because we can list the possible values. Often, continuous variables are rounded to a discrete set of values. Most people round their height to the nearest inch (or half inch). Statistics 371, Fall 2003 2

Summaries of Categorical Variables A frequency distribution is a list of the observed categories and a count of the number of observations in each. A frequency distribution may be displayed with a table or with a bar chart. For ordinal categorical random variables, it is conventional to order the categories in the display (table or bar chart) in the meaningful order. For non-ordinal variables, two conventional choices are alphabetical and by size of the counts. The vertical axis of a bar chart may show frequency or relative frequency. It is conventional to leave space between bars of a bar chart of a categorical variable. Statistics 371, Fall 2003 4 Summary of Majors > cbind(summary(major)) [,1] Animal Science 2 Bacteriology 1 Biochemistry 3 Biological Aspects of Conservation 2 Biology 19 Biology/Zoology 1 Biomedical Engineering 9 Botany 1 Dairy Science 1 Forestry 1 Genetics 31 Graduate student in Bacteriology 1 Kinesiology 4 Medical MicroBiology and Immunology 1 Molecular Biology 1 Nursing 1 Plant Pathology 1 Possibly Kinesiology 1 Undecided 1 Wildlife Ecology 5 Wildlife Ecology - Natural Resources 1 Zoology 11 Statistics 371, Fall 2003 6 Samples A sample is a collection of units on which we have measured one or more variables. The number of observations in a sample is called the sample size. Common notation for the sample size is n. The textbook adopts the convention of using uppercase letters for variables and lower case letters for observed values. Summary of Blood Type Data Here is a frequency table. > summary(bloodtype) A AB B O NA s 25 12 3 22 37 Here is a bar chart. > barplot(summary(bloodtype)) 0 5 15 25 35 A AB B O NA s Statistics 371, Fall 2003 3 Statistics 371, Fall 2003 5

Summaries of Quantitative Variables Quantitative variables from very small samples can be displayed with a dotplot. Histograms are a more general tool for displaying the distribution of quantitative variables. A histogram is a bar graph of counts of observations in each class, but no space is drawn between classes. If classes are of different widths, the bars should be drawn so that areas are proportional to frequencies. Selection of classes is arbitrary. Different choices can lead to different pictures. Too few classes is an over-summary of the data. Too many classes can cloud important features of the data with noise. Summary of Miles from CSSC > hist(milescssc, col = 3) Histogram of MilesCSSC 0 20 40 60 80 0 10 20 30 40 MilesCSSC Statistics 371, Fall 2003 8 Statistics 371, Fall 2003 10 Summary of Second Majors > cbind(summary(major2)) [,1] 69 Anthropology 1 Bacteriology 4 Biochemistry 2 Biological Aspects of Conservation 2 Biology 2 Dietetics 1 Economics 1 Entomology 1 French 1 Genetics 1 Horticulture 1 IES 2 Life Science Communication 1 Math 2 Physics 1 Plant Pathology 1 Political Science 1 Psychology 1 Scandinavian Studies 1 Spanish 1 Wildlife Ecology 2 Statistics 371, Fall 2003 7 A Dotplot of Hours of Sleep > source("../r/dotplot.r") > dotplot(sleep) 5 6 7 8 9 Statistics 371, Fall 2003 9

Summary of Miles from Home for Students within 150 miles > hist(mileshome[mileshome < 150], col = 3) Histogram of MilesHome[MilesHome < 150] 0 2 4 6 8 10 12 14 Stem-and-Leaf Diagrams Stem-and-Leaf diagrams are useful for showing the shape of the distribution of small data sets without losing any (or much) information. Begin by rounding all data to the same precision. The last digit is the leaf. Anything before the last digit is the stem. In a stem-and-leaf diagram, each observation is represented by a single digit to the right of a line. Stems are shown only once. Show stems to fill gaps! Combining or splitting stems can lead to a better picture of the distribution. 0 50 100 150 MilesHome[MilesHome < 150] Statistics 371, Fall 2003 12 Statistics 371, Fall 2003 14 Summary of Miles from Home > hist(mileshome, col = 3) Histogram of MilesHome Summary of Height > par(mfrow = c(1, 2)) > hist(height[keep], col = 2) > hist(height[keep], breaks = breaks, col = 3) Histogram of Height[keep] Histogram of Height[keep] 0 20 40 60 80 0 5 10 15 0 2 4 6 8 10 0 5000 10000 15000 20000 MilesHome 60 65 70 75 Height[keep] 60 65 70 75 Height[keep] Statistics 371, Fall 2003 11 Statistics 371, Fall 2003 13

Stem-and-Leaf of Miles from CSSC The decimal point is at the 0 12223333335555555555555578888888800000000000000000000000000022355555 2 000000005000 4 0000 6 0 8 00 10 12 14 0 16 18 20 22 24 0 26 28 30 32 34 36 38 40 0 Statistics 371, Fall 2003 16 Measures of Center There are two common measures of center for quantitative variables, the mean and the median. For sample data y 1, y 2,..., y n, the sample mean is n y i i=1 ȳ = n The sample mean is the balancing point of the variable. The sample median is the middle value at least half the values are larger and at least half are smaller. If a sample size is odd, only one number will be the median. If a sample size is even, any number between the middle two numbers could be the median. By convention we take the average of the middle two numbers. Imagine a histogram made of a uniform solid material. The mean is about the point at which the solid would balance. The median is about at a point that would divide the area of the histogram exactly in half. Statistics 371, Fall 2003 18 Stem-and-Leaf Diagram of Brothers and Sisters > stem(brothers, scale = 0.5) The decimal point is at the 0 00000000000000000000000000000000 1 000000000000000000000000000000000000000000 2 0000000000000000 3 0000000 4 00 > stem(sisters, scale = 0.5) The decimal point is at the 0 000000000000000000000000000000000000000000 1 0000000000000000000000000000000000000000 2 000000000 3 00000 4 000 Skewness Histograms show several qualitative features of a quantitative variable, such as the number of modes and skewness. A distribution is approximately symmetric if the left and right halves are approximately mirror images of each other. A distribution is skewed to the right if the right half of the data (the larger values) are more spread out than the left half of the data. A distribution is skewed to the left if the left half of the data (the smaller values) are more spread out than the right half of the data. It is fairly common for biological data to be skewed to the right. Often times there is a barrier below which there can be no values, but no upper limit. Statistics 371, Fall 2003 15 Statistics 371, Fall 2003 17

Quantiles Quantiles are a generic name for positions in the distribution of a quantitative variable. For example, percentiles divide a distribution into 100 equal sized parts. Quartiles. which divide a distribution into four equal sized parts are a common statistical tool. The first quartile, Q 1, is the location that separates the smallest quarter of the data from the rest. This is also known as the 25th percentile. The third quartile, Q 3, is the location that separates the top quarter of the data and is also known as the 75th percentile. The median is the second quartile. Different authors and statistical software packages have different definitions of quantiles. The definition I prefer is that a value x is a p quantile of a sample if the proportion of observations less than or equal to x is at least p and if the proportion of observations greater than or equal to x is at least 1 p. Statistics 371, Fall 2003 20 Boxplots In a simple boxplot, a box extending from the first to third quartiles represents the middle half of the data. The box is divided at the median, and whiskers extend from each end to the maximum and minimum. It is common to draw more sophisticated boxplots in which the whiskers extend to the most extreme observations within upper and lower fences and individual observations outside these fences are labeled with individual points as potential outliers. The most common rule defining the fences are that they are 1.5 IQR below the first quartile and 1.5 IQR above the third quartile. Statistics 371, Fall 2003 22 Comparing the mean and the median The mean and median of a symmetric distribution are the same. The median is more resistant to outliers than the mean. For example, the mean and median of the numbers 1, 2, 3 are 2, but for the data set 1, 2, 30, the median is still 2, but the mean is 11, far away from each observation. The median can be a better measure of a typical value than the mean especially for strongly skewed variables. If a variable is skewed to the right, the mean will typically be larger than the median. The opposite is true if the variable is skewed to the left. Example: > mean(mileshome) [1] 760.2917 > median(mileshome) [1] 117.55 Statistics 371, Fall 2003 19 5 Number Summary The minimum, first quartile, median, third quartile, and maximum are called the five-number summary of a quantitative variable. The interquartile range (IQR) is the difference between the third and first quartiles. IQR = Q 3 Q 1 The range is the difference between the maximum and the minimum. Graphical displays of five-number summaries are called boxplots. Example: > fivenum(milescssc) [1] 0.1 0.7 1.0 1.5 40.0 Statistics 371, Fall 2003 21

Boxplot of Miles from CSSC > boxplot(milescssc) Boxplot of Hours of Sleep > boxplot(sleep) 5 6 7 8 9 0 10 20 30 40 Measures of Dispersion The standard deviation or SD is the most common statistical measure of dispersion. A deviation from the mean is the signed distance of an observation from the mean. deviation = value of observation mean Observations greater than the mean have positive deviations while those less than the mean have negative deviations. The standard deviation is a special type of average deviation n (y i ȳ) 2 i=1 s = n 1 This is almost the square root of the mean squared deviation from the mean. Statistics 371, Fall 2003 24 Statistics 371, Fall 2003 26 Side-by-side boxplot of height versus sex > boxplot(split(height, Sex)) 60 65 70 75 Female Male Statistics 371, Fall 2003 23 Statistics 371, Fall 2003 25

The Empirical Rule For many variables (especially those that are nearly symmetric and bell-shaped), the following empirical rule is often a very good approximation. About 68% of the observations are within 1 SD of the mean. About 95% of the observations are within 2 SDs of the mean. Nearly all observations are within 3 SDs of the mean. Example: > m = mean(sleep) > s = sd(sleep) > m [1] 6.868687 > s [1] 0.8736093 > sum(abs(sleep - m) < s)/length(sleep) [1] 0.7272727 > sum(abs(sleep - m) < 2 * s)/length(sleep) [1] 0.949495 > sum(abs(sleep - m) < 3 * s)/length(sleep) [1] 1 Statistics 371, Fall 2003 27 Measures of Dispersion Statisticians use n 1 instead of n in the denominator for a technical mathematical reason of historical, if not practical, importance. The standard deviation can often be interpreted as the size of a typical deviation from the mean. Samples and Populations The previous techniques are useful for describing a data set, or a sample of data. It is often of interest to generalize findings from a sample to a larger group that statisticians call a population. This generalization is called statistical inference. Statistical inference is often concerned with using statistics, characteristics that can be calculated from sample data, to estimate parameters, characteristics of populations. Examples: p = population proportion, ˆp = sample proportion µ = population mean, ȳ = sample mean σ = population standard deviation, s = sample standard deviation Statistics 371, Fall 2003 26 Statistics 371, Fall 2003 28