Statistics is... a collection of techniques for planning experiments, obtaining data, and then organizing, summarizing, presenting, analyzing, interpreting, and drawing conclusions based on the data... statistics uses data to gain understanding, to answer questions…or as the textbook says: “the science of learning from data” A dataset is… a collection of information about individuals "measured" on variables
A variable is… any characteristic of an individual or observation. a variable takes on different values for different observations… the distribution of a variable tells us what values it takes on and with what frequency or relative frequency. We are interested in analyzing the distributions of variables both graphically and numerically … Variables come in two basic varieties… categorical - puts an individual into categories or into its levels quantitative - takes on numerical values, like measurements or counts or rates
Two types of variables Variables can be either quantitative… –Something that can be counted or measured for each individual and then added, subtracted, averaged, etc. across individuals in the population. –Example: How tall you are, your age, your blood cholesterol level, the number of credit cards you own, your heart rate … or categorical. –Something that falls into one of several categories. What can be counted is the count or proportion of individuals in each category. –Example: Your blood type (A, B, AB, O), your hair color, your ethnicity, whether you paid income tax last tax year or not
How do you know if a variable is categorical or quantitative? Ask: What are the n individuals/units in the sample (of size n)? What is being recorded about those n individuals/units? Is that a number ( quantitative) or a statement ( categorical)? Individuals in sample DIAGNOSISAGE AT DEATH Patient AHeart disease56 Patient BStroke70 Patient CStroke75 Patient DLung cancer60 Patient EHeart disease80 Patient FAccident73 Patient GDiabetes69 Quantitative Each individual is attributed a numerical value. Categorical Each individual is assigned to one of several categories.
Here's an example from a set of data we will look at later with R … note that it is a spreadsheet … How many variables are there? Which are categorical? Which are quantitative? How a set of data is obtained is really important and we'll be looking into this in Chapter 3 …
So how do we read that dataset into R? Here are the commands to read in Table 1.1 of service times… #First right-click on "Data Sets" for Table 1.1 #in the textbook. Left-click and "copy link location" # of the ASCII (text) file… Use the read.table #command as follows: ServiceTimes = read.table(file="then paste the link ") str(ServiceTimes) head(ServiceTimes) hist(ServiceTimes$length) stem(ServiceTimes$length) #there are many other statistics commands in R you can #use to describe the service time data…
Graphical analysis of data Graphs help us visually understand the distribution of a variable… The type of graph used in an analysis depends on the type of variable. For categorical variables, we use bar graphs or pie charts For quantitative variables, we use histograms or stemplots or … In the special circumstance that observations are ordered in time, we can make time plots to look for trends in the variable over time…
Once a graph of the variable is made, we can begin to understand its distribution by looking at the following: –look at the overall pattern in the graph and for striking deviations from that overall pattern. Peaks? Gaps? Symmetric? Skewed? –describe the overall pattern of the distribution by talking about its shape, center, and spread (or variation). –look for possible outliers in the distribution; i.e., those values of the variable that seem to fall outside the overall pattern you see. These features will be important for all types of graphs…
For categorical variables, the best we can do is count the number of observations in each category (and compute the percent in each category). The bar graph plots the counts or percents falling in each of the categories… below is the distribution of the highest educational level of people in the U.S. aged years…see p.7
Example: Top 10 causes of death in the United States 2001 RankCauses of deathCounts % of top10 % of total deaths 1Heart disease700,14237%29% 2Cancer553,76829%23% 3Cerebrovascular163,5389%7% 4Chronic respiratory123,0136%5% 5Accidents101,5375%4% 6Diabetes mellitus71,3724%3% 7Flu and pneumonia62,0343% 8Alzheimer’s disease53,8523%2% 9Kidney disorders39,4802% 10Septicemia32,2382%1% All other causes629,96726% For each individual who died in the United States in 2001, we record what was the cause of death. The table above is a summary of that information. Why are the percentages in the two columns different??
Child poverty before and after government intervention—UNICEF, 1996 What does this chart tell you? The United States has the highest rate of child poverty among developed nations (22% of under 18). Its government does the least—through taxes and subsidies—to remedy the problem (size of white bars and percent difference between white/blue bars). One problem with this graph is the different years’ data... The poverty line is defined as 50% of national median income.
Ways to graph quantitative data Line graphs: time plots –Use when there is a meaningful sequence, like time. The line connecting the points helps emphasize any change over time. Histograms and stemplots –These are summary graphs for a single variable. They are very useful to understand the pattern of variability in the data. Other graphs to reflect numerical summaries.
Line graphs: time plots A trend is a rise or fall that persist over time, despite small irregularities. In a time plot, time always goes on the horizontal, x axis. We describe time series by looking for an overall pattern and for striking deviations from that pattern. In a time series: A pattern that repeats itself at regular intervals of time is called seasonal variation.
For quantitative variables, we'll consider both stemplots and histograms - stemplots are much easier to draw and interpret… see the box on page 10 and consider the female literacy rates in Islamic countries in Ex.1.7 The tens digit become the stem, and the units digit becomes the leaf (see Fig. 1.5)
Histograms break up the range of values of the variable into intervals (on the horizontal axis) and displays (on the vertical axis) the count (or percent) of observations falling into those intervals - choosing the number of intervals and/or the width of the intervals can be problematic… usually histograms are made by computer programs (like R). See Fig. 1.7, p. 14. Data is in table 1.3, p. 13
Homework Carefully read sections 1.1 and 1.2 Work through the examples in those two sections… Work the following problems: # (these are scatted throughout section 1.1), , 1.17, 1.18, 1.20, 1.21, 1.23, 1.24, 1.25, 1.27, 1.37 Use R or an Applet for the following problems: , 1.39, 1.42, We'll have our first quiz soon….