Docsity

Appunti data analysis 2021/2022, Appunti di Statistica

Toggle sidebar
bg1
CLASS 6 – INFERENCES
DESCRIPTIVE STATISTICS
summarize information from collected data
(usually a sample, but also populations). We
summarize the information using a
statistic.
INFERENTIAL STATISTICS provide
predictions about a population, based on
data from a sample of that population. A
numerical summary of a population is given by
a parameter.
Since parameters are generally unknown we
need to estimate them, we take a guess. There are two types of estimates of parameters:
A POINT ESTIMATE is a single number that is the best guess for the parameter
An INTERVAL ESTIMATE is an interval of numbers amount the point estimate, within which the
parameter is estimated to fall
An estimator refers to a particular type of statistic for estimating a parameter. You can think of it as a tool.
For example, the sample proportion is an estimator of the population proportion.
The term estimate refers to its value for a specific sample. In the example of the previous class, 56% of the
sample reported voting for a given candidate: this is the estimate.
A good estimator has a sampling distribution that is: centered around the parameter (unbiased) and hasa
small standard error (efficient).
An ESTIMATOR IS UNBIASED if its sampling distribution centers around the parameter. For any particular
sample, the mean can vary, sometimes overestimating and sometimes underestimating the true value.
However, if the sample mean is repeatedly found, then the over and under estimations will balance
The range is typically a BIASED ESTIMATOR because it can never be larger than the actual range of the
population, so it will always underestimate it.
A good estimator has as small a standard error as possible. It falls closer to the parameter than other
estimators. For example, when a population distribution is normal, the standard error of the sample is 25%
larger than the standard error of the sample mean. The sample mean is an efficient estimator. The sample
median is an inefficient estimator.
Often we use the sample analog of a population parameter as its estimator.
e.g. the sample proportion is an unbiased and efficient estimator of the population proportion
e.g. the sample mean y is an unbiased and (usually) efficient estimator of the population mean
^ caret or hat u^ denotes an estimate of the population mean u
MAXIMUM LIKELIHOOD ESTIMATION: Ronal A Fisher
The observed statistic would have had a greater chance of occurring if the parameter equaled that number,
than if the parameter equaled any other number.
To be truly informative, an inference should provide also an indication of how close the estimate is likely to
fall to the parameter value. This it given by the width of an interval estimate around the parameter.
EXAMPLE
18
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23

Anteprima parziale del testo

Scarica Appunti data analysis 2021/2022 e più Appunti in PDF di Statistica solo su Docsity!

CLASS 6 – INFERENCES

DESCRIPTIVE STATISTICS 

summarize information from collected data (usually a sample, but also populations). We summarize the information using a statistic. INFERENTIAL STATISTICS  provide predictions about a population, based on data from a sample of that population. A numerical summary of a population is given by a parameter. Since parameters are generally unknown we need to estimate them, we take a guess. There are two types of estimates of parameters:  A POINT ESTIMATE is a single number that is the best guess for the parameter  An INTERVAL ESTIMATE is an interval of numbers amount the point estimate, within which the parameter is estimated to fall An estimator refers to a particular type of statistic for estimating a parameter. You can think of it as a tool. For example, the sample proportion is an estimator of the population proportion. The term estimate refers to its value for a specific sample. In the example of the previous class, 56% of the sample reported voting for a given candidate: this is the estimate. A good estimator has a sampling distribution that is: centered around the parameter (unbiased) and hasa small standard error (efficient). An ESTIMATOR IS UNBIASED if its sampling distribution centers around the parameter. For any particular sample, the mean can vary, sometimes overestimating and sometimes underestimating the true value. However, if the sample mean is repeatedly found, then the over and under estimations will balance The range is typically a BIASED ESTIMATOR because it can never be larger than the actual range of the population, so it will always underestimate it. A good estimator has as small a standard error as possible. It falls closer to the parameter than other estimators. For example, when a population distribution is normal, the standard error of the sample is 25% larger than the standard error of the sample mean. The sample mean is an efficient estimator. The sample median is an inefficient estimator. Often we use the sample analog of a population parameter as its estimator.  e.g. the sample proportion is an unbiased and efficient estimator of the population proportion  e.g. the sample mean y is an unbiased and (usually) efficient estimator of the population mean ^ caret or hat  u^ denotes an estimate of the population mean u MAXIMUM LIKELIHOOD ESTIMATION : Ronal A Fisher The observed statistic would have had a greater chance of occurring if the parameter equaled that number, than if the parameter equaled any other number. To be truly informative, an inference should provide also an indication of how close the estimate is likely to fall to the parameter value. This it given by the width of an interval estimate around the parameter. EXAMPLE 

The confidence interval for a parameter is an interval of numbers within which the parameter is believed to fall. The confidence level is a number chosen to be close to 1, such as 0.99 or 0.95 The confidence level is the probability that this method produces an interval that contains the true population parameter. The key to constructing the confidence interval is the sampling distribution of the point estimator. For categorical data, an observation falls in one of a set of categories. Nominal and ordinal variables or recording of continuous variables. To summarize categorical data we use proportions or percentages. EXERCISE 1  Of 577,006 people involved in motor vehicle accidents in Florida in a recent year, 412, were wearing seat belts. Find a point estimate of the population proportion of Florida motorists wearing seat belts. Point estimate of the population proportion of Florida motorists wearing seat belts 421,878/577,006= 0, EXERCISE 2  In ESS8 for 2016, 7270 subjects said they posted something on the internet about politics, while 36941 did not post anything. Find a point estimate of the population proportion of Europeans who posted about politics. Point estimate of the population proportion of Europeans who posted about politics 7270/(7270+36941)= 0, Recall that the sample proportion is a mean when y=1 for a given category an y=0 otherwise. Similarly, the population proportion π is the men u of the probability distribution having probabilities. P(1) = π and P(0) = 1 – π Since the sample proportion is a sample mean, the central limit theorem applies. For large random samples, the sampling distribution of π is approximately normal about the parameter π estimates.

The larger the n, the smaller the margin of error and therefore the interval. ERROR PROBABILITY The probability that the estimation yields a confidence interval that does not contain the parameter is called the error probability. For a confidence level of 0.95 the error probability equals 1- 0,95 =0.05. It is denoted by alfa The z-value for the confidence interval is such that the probability is alfa that π falls more than z standard deviations away from π. The z-value stands for the total probability of alfa in the two tails of the normal distribution. For a 95% confidence interval, alfa=0.05 and the z-score is the one with probability alfa/ =0.05/2= 0.025 in each tail. What value of z does this correspond to? LONG-RUN PROPORTION CORRECT The confidence level for the confidence interval describes how the method performs when used over and over with many different random samples. If we constructed many random samples of a given size, we would get many different confidence intervals. In the long run, 95% of the intervals would contain the true population proportion π. This happens because 95& of the sample proportions would fall within 1,96(se) of π. It is like saying that the inference is correct 95% of the times. In reality, we do not have multiple samples: we generally only have one sample with a fixed sample size n and we construct one confidence interval. We do not know whether that confidence interval truly contains π. Our confidence is based on the long-term properties of the procedure. THE IMPORTANCE OF LARGE SAMPLE SIZES As n increases, the sampling distribution of π is closer to normal by the CLT. This is what allows us to use z-scores from the normal distribution to find the margin of error. As n increases, the estimated standard error gets closer to the true standard error and for this reason, the confidence interval formula applies to large sample sizes. General rule: have at least 15 observations both in the category of interest and not in it. CONFIDENCE INTERVAL FOR A MEN The point estimate for the population mean u is the sample mean y. for large random samples, by the CLT, the sampling distribution of y is approximately normal. Therefore, we can again find a margin of error by multiplying a z-score from the normal distribution times the standard error. Since this value is unknown, we estimate the standard error using the standard deviation of the sample. 

EXAMPLE  A survey asked how many sexual partners a sample of 231 women had since their 18th birthday. The mean value of the sample is 4,96. The sample standard deviation if 6,81. The estimated standard error of the sample if: se= 6.81/radice 231= 0.45. The 95% confidence interval is:  4,96 – (1,96x0.45)= 4,  4,96 + (1,96x0.45)= 5, In several random samples of 231 women, the sexual number of partners would vary from sample to sample with a standard error of about 0.45. the 95% confidence interval is an interval estimate of u. we can be 95% confident that this interval contains u. The point estimate of u is about 5 and the interval estimate predicts that u is no smaller than 4.1 and no greater than 5,8. T-DISTRIBUTION Using the estimate standard error se introduces extra error. If the sample size n is small, this error can be sizeable. We use the t-distribution instead of the z-distribution because its shape is slightly more spread out and the tail values are larger. Bell-shaped, symmetric, mean= 0, sd= The precise value depends on the degrees of freedom n-1. The larger the sample size, the closer the t- distribution is to the standard normal. A t-score multiplied by the estimated standard error gives the margin of error for a confidence interval for the mean. EXAMPLE  For a simple of size 29, df=28. T.035= 2.048. When df=28 the probability equals 0. between -2.048 and 2. Confidence intervals for the mean resemble those of a proportion. Except they use a t- distribution. For a random sample for a normal population distribution, a 95% confidence interval for the populations men u is y +- t0.025(se).

 The null hypothesis (H0) is a statement that the parameter takes a certain value: it usually states that there is no difference between two parameters.  The alternative hypothesis (Ha) states that the parameter falls in some alternative range: it usually states that there is a difference between two parameters. EXAMPLE  (QUANTITATIVE OUTCOME) H0: higher and lower educated people have roughly the same income – Ha: higher educated people have higher income then less educated ones. (BINARY OUTCOME) H0: smokers and non-smokers do not differ in the probability of developing lung cancer. Ha: smokers are more likely to develop lung cancer than non-smokers. EXERCISE  develop a null hypothesis and an alternative hypothesis of you choice for an outcome that is: Quantitative:  Minutes  Income  Annual carbon dioxide emission per capita Categorical:  Party voted  Taking the bus or the car to commute  Being vegetarian or not TEST STATISTIC : a significance test analyses the sample evidence about the null hypothesis H0. The test investigates whether the data contradict the null, proof by contradiction. The test statistic summarizes how far that estimate falls from the parameter value in H0. P-VALUE: to interpret the test statistic, we create a probability summary of the evidence against H0. This uses the sampling distribution of the test statistic, under the assumption that H0 is true. The purpose is to summarize how unusual the test statistic value is compared to the value predicted by H0. If the test statistic falls out in the tail of the sampling distribution in the direction predicted by Ha, then it is far from what H predicts. We can summarize how far by the tail probability of that value and other more extreme ones. This probability is called P-value. The smaller the P-value, the stronger the evidence against H0. Conclusion: the P-value helps reaching a conclusion. If it is very small, then it is unlikely that we would get such a result if it did not reflect the population parameter. The usual threshold to reject H0, is p <= 0,05. It means that if H0 were true, the chance of getting such an extreme result in the data would be no greater the 0,05 or 5%. SIGNIFICANCE TEST FOR A MEAN:  The null hypothesis about the population mean u has the form: H0 : U = U0 where u0 is a particular value for the population mean.  The alternative hypothesis has the form Ha : u =/ u0 so we say that Ha is two-side: the value can be smaller or larger than u  The alternative hypothesis can also be one sides Ha : u > u The sample mean y estimates the population mean u. Under the assumption that the null is true (H0 : U = U0), the centre of the sampling distribution of y is the value u0.

It would be very unusual to find y so far our if u= u0. This is strong evidence against H0. It is summarized by the number of standard errors that y falls away from the null hypothesis value u0. The test statistics that we are going to use is: The larger the absolute value of t: the farther y falls from u0 and the stronger the evidence against H0. To interpret t we transform it into a probability on the 0-1 scale: P-value. The P-value is the probability that the test statistic equals the observed value (or is more extreme). It is also the probability that y falls at least as far from u0 in either direction as the observed value of y. The smaller the P is, the stronger the evidence against H0 and in favour of Ha. EXAMPLE  Hypothesis:  H0 : u = 4 the null hypothesis that the mean in the black population is 4  Ha : u =/ 4 the alternative states that the mean in the black population is not 4 Test statistics:  Mean value for the subset of black respondents y = 4.  The standard deviation is s= 1.  The standard error is se = 0.  T= (4.075-4.0)/ 0.111 = 0.  The sample mean falls 0.68 standard error above the null hypothesis value  t= 0.68, p= 0.  The two-tail probability is P= 0.  If the population mean were 4, then there is a 50% probability that we would find a value of 4. in our sample.  Another useful and smart thing to do is to construct the confidence interval. With df: 185, the multiple of the standard error is 1.97  4.075 +- 1,97(0.111) = 4.075 +- 0.219 = (3.9, 4.3)  At the 95% confidence level, there are plausible values for u. The population mean u might equal 4, because the confidence interval is (3.9, 4.3) In the TWO-SIDED TEST:  P > 0.05: whenever the P-value is greater than 0.05, the 95% confidence interval contains the H values of u  P < 0.05: whenever the P-value is smaller than 0.05, the 95% confidence interval does not contain the H0 value of u ONE-SIDED TEST:  H0 : u > u0 or H0 : u < u

EXAMPLE  Random sample of 1200 subjects in Florida. When asked about how to solve budget limitations 52% raise taxes and 48% reduce services. Let π denote the population in Florida that would chose to raise taxes.  If π < 0.50 this is a majority of the population  If π > 0.50 this is a majority  To analyze which it is, we test H0 : π = 0.50 against Ha : π =/ 0.  The estimate of π is 0.52, se = 0.0144, z= 1.39  p= 0.0823X2 = 0.  The P-value is not small enough to reject H0.  At the same time, we cannot say that we accept H0. Consider the confidence interval (0.49, 0.55). The interval contains the possible values for π. TYPES OF ERRORS : because of sampling variability, decisions in tests are always uncertain. It is possible that we make an errorneous decision. There are two types of potential errors: type I error and type II error.  Type I: reject the null when it is true  Type II: fail to reject the null when it is false EXAMPLE  According to Eurostat, the unemployment rate in Italy in September 2019 was 9.7%. A mayor of a small town wanted to find out if the unemployment rate in her own town was significantly different from 9.7% by taking a random sample of her residents. Let p represent the unemployment rate in her town. She tests the following hypotheses: H0 : p = 0.097 and Ha : p = 0.097. Which would be a type I error?  Is not 9.7% when it actually is  TYPE I ERROR  Is 9.7% when it actually is  CORRECT DECISION  Is not 9.7% when it actually is not  CORRECT DECISION  Is 9.7% when it actually is not  TYPE II ERROR REJECTION REGIONS : the collection of test statistic values for which the test rejects H0 is called the rejection region. For example, the rejection region for a test of level a = 0:05 is the set of test statistic values for which P B 0:05. In two-sided tests for a proportion, the two tail P-value is B 0:05 when SzS C 1:96. The rejection region consists of values of z resulting from the estimate falling at least 1.96 standard errors from the H0 value Probability of type I error: the smaller the probability of a type I error, the large the probability of a type II error. Limitations of significance tests: a significance test tells us whether a parameter differs from the H0 value. It is not informative about how much it differs and whether this difference is of practical importance. Statistical significance  small P-value vs practical significance  size of the effect

CLASS 8 – COMPARING TWO GROUPS

Comparing groups is very common in the social sciences. Recall the examples from the previous class: differences in housework time among women and men, income among people with different levels of education, cancer among smokers and non-smokers.

EXPLANATORY OR INDEPENDENT VARIABLES vs RESPONSE OR DEPENDENT VARIABLES. We have a dependent variable that we want to study, and we use an explanatory outcome to predict its variation. In the first examples, gender is the dependent variable (response) while education is the independent (explanatory) EXERCISE  identify the response variable and the explanatory variable Quantitative:  Minutes  Income  Annual carbon dioxide emission per capita Categorical:  Party voted  Taking the bus or the car to commute  Being vegetarian or not EXAMPLE  let’s consider as example gender different in housework. Sex is a binary explanatory variable (independent). Minutes of a housework is a continuous response variable (dependent). For the two population means u1 and u2, we can estimate their difference. We treat u2 – u1 as a parameter. We estimate it through the sample difference y2 – u STANDARD ERROR OF DIFFERENCES : the difference between the two estimates has a standard error that describes how precisely it estimates the parameter. In the example y2 – y1 = 14. If multiple samples of the same size were taken, the value would not always be exactly 14. Sometimes it would be bigger and sometimes smaller. The standard error describes the variability of the estimates from different samples of the same size. For two estimates from independent samples that have estimated standard error se1 and se2 the sampling distribution of their difference is Each estimate has sampling error. The variabilities add together to determine the standard error of the difference of the estimates. Differences of estimates and their se: for large sample sizes, the estimate of the difference would not vary much. Confidence interval for u2 – u1: to compare two means u1 – u2, we can make inference about their difference. For independent random samples from two groups that have normal population distributions, a confidence interval for the difference u2 – u1 is The t-score depends on the chosen confidence level. The formula for the degrees of freedom for the t-score is complex and we generally use software at this stage.

Confidence interval: for large independent random samples, the confidence interval for the difference π2- π1 is  From the example above we get (-0.07, 0.04). The confidence interval is close to and contains zero. Meaning that the probability of complications is similar for the two groups. Insufficient evidence exists to conclude which of π1 and π2 is larger. We reject the null hypothesis. Significance tests: under the assumption that π1 = π2, we estimate the common value of π1 and π2 by the sample proportion of the entire sample. The pooled estimate is the value that ignores difference between the groups. From the example above, the estimate common value of π1 and π2 is π= (315+304)/(604+597)= 0.515. The standard error from our example is se= 0.0288. The test statistic is z= (0.509-0,522)/0.0288 = -0.43. The corresponding two-sided p-value is 0.67; therefore, there is little evidence against H0. We conclude that the probability of complications is equally likely among the prayer and non-prayer groups. EXERCISE 2  According to the National Health Interview Survey, the American adults who smoke were: 41.9% of in 1965, 21,5% in 2003. Se= 0.020 for each proportion.  Estimate the difference between the proportions of subjects who smoked in the two years  0.215-0.419= 0.  Find the standard error of the difference and interpret  se= 0. EXERCISE  According to a Eurobarometer survey, 0.52 of respondents in Denmark (n=1008) would pay more for renewable energy. In Lithuania (n=1002) the proportion was 0.  Estimate the difference between the two proportions  0.14-0.52= -0.  Estimate the standard errors of the two proportions  se1= 0.0157, se2= 0.  Find the standard error of the difference  se= 0. Dependent vs independent samples: samples that have subjects repeated over time or where some form of matching between subjects exists are called dependent samples. With dependent samples, matched responses are likely to be associated and standard errors must be adjusted accordingly.

CLASS 9 – CROSSTABS

ASSOCIATION BETWEEN VARIABLE s. An association exists between two variables if the distribution of the response variable changes as the value of the explanatory variable changes. If one changes, the other changes because there is a connection between them. Is there a relationship between gender and party identification? Between political participation and religious affiliation? Between race and level of education? There are many different ways to assess there relationships. CONTINGENCY TABLES. For the analysis of categorical variables, we start from contingency tables. A contingency table displays the number of subjects observed at all possible combinations of possible outcomes of the two variables. Just looking at the frequencies does not tell us much about the association between two variables. The next step is to convert the frequencies into percentages.  we divide the value in each cell for the total of the corresponding group to get the conditional distribution of gender on party identification. For women: 573/1511= 0.38 – 516/1511= 0.34 – 422/1511 = 0.

Democrat: more women than men. Independent: more men than women. Republican: more men than women. When calculating the percentages it is standard to form the conditional distribution for the response variable within categories of the explanatory variable. If we do, the opposite, we get the composition by gender of the response variable party ID. 60% of the democrats are women, but this says little on the association between gender and political ID. GUIDELINES FOR TABLES AND GRAPHS. Clearly label the variables and their categories. Provide an informative title. Include the total sample size on which the percentages were calculated. STATISTICAL INDEPENDENCE AND DEPENDENCE. Two categorical variables are statistically independent if the population conditional distributions on one of them are identical at each category of the other. The variables are statistically dependent if the conditional distributions are not identical Its about the population, not the sample. The concepts of statistical independence and statistical dependence refer to the population, not the sample. EXAMPLE  statistical independence. The conditional distributions are identical in each category. EXAMPLE  statistical dependence. The conditional distributions are different in each category.

H0: party ID and gender are statistically independent Ha: parti ID and gender are statistically dependent X^2 = 16.2 and P < 0.001  if the variables were independent in the population, it would be highly unusual to find such a large X^2 statistic in a random sample. EXERCISE  calculate the conditional distributions of the response variable. What does the sample data suggest: are religion and obedience dependent or independent? There appears to be a relationship between religion and obedience For Catholics, Islamic and the not religious category, calculate the expected frequencies of answering like me if H0 is true.  fe= the product of the row and column total for that cell, divided by the total sample size. LIMITS OF SIGNIFICANCE TEST. The X^2 tell us nothing about the nature or the strength of the association between two variables. RESIDUAL ANALYSIS. We can do a cell-by-cell comparison of observed and expected frequencies to find the nature of the evidence about the association. In the example, for the first cell (fo-fe)= 573-522.9= 50.1. This difference is called a residual. This residual is positive because the observed frequency exceeds the expected frequency. Standardized residual for a cell: is this difference large enough to indicate a departure from independence that is unlikely to be due to mere chance? The standardized residual is the number of standard errors that fo-fe falls from the value of 0 that we expect when H0 is true. If H0: independence iss true, the standardized residuals have a large-sample standard normal distribution with u= circa 0 and .. = circa 1. When H0 is true, there is only a 5% chance that any particular standardized residual exceeds.

MEASURES OF ASSOCIATION. A measure of association summarizes the strength of the dependence between two variables.  Is there an association? Chi square test of independence and P-value  How do the data differ from what independence predicts? Standardized residuals  How strong is the association? Differences in proportions with confidence intervals STRONG VS WEAK ASSOCIATIONS. Case A: statistical independence – Case B: statistical dependence An easy way to measure association is the difference in the proportions for a category:  Case A: 360/600 – 240/400= 0.60 – 0,60 = 0  Case B: 600/600 – 0/400= 1 – 0 = 1 The stronger the association, the larger the absolute value of the difference of proportions. X^2 does not measure association  A large value of X^2 suggest that the variables are associated  It does not imply that the variables have a strong association  It indicates how much evidence there is that the variables are not independent  Large values of X^2 occur with larger sample sizes

One inferential method for comparing means for different groups is to use the analysis of variance, also called ANOVA. Developing by Fisher, at the heart of analysis there is a significance test, using the F distribution, for detecting differences among a set of population means. Let g denote the number of groups to compare (such as g=3 three groups). The means of the response variable for the corresponding population are u1, u2, u3. The sample means are y1, y2, y3.  the analysis of variance ANOVA is an F test for:  H0: u1 = u2 = … = ug  Ha : at least two of the population means are unequal If H0 is false, perhaps all the populations means differ, perhaps some differ, or perhaps only one differs from the rest. The test analyses whether the differences observed among the sample means could have reasonably occurred by chance, if H0 were true. Assumption of the F test:  For each group, the population distribution of the response variable y is normal  The standard deviations of the population distribution is the same for each group. Denote the common value by a  The samples from the population are independent random samples EXAMPLE  Political ideology: 1 = extremely liberal and 7 = extremely conservative H0 : u1 = u2 = u  U1 is the population mean ideology for democrats  U2 is the population mean ideology for independents  U3 is the population mean ideology for republicans The test statistic compares two estimates of variance a^2 for each group.  Variability between groups: it estimates the variability between each sample mean y, and the overall mean y.  Variability within groups: it estimates the variability within each group of the sample observations around their several means.

Generally, the greater the variability between sample means, and the smaller the variability within each group, the stronger the evidence against the null of equal population. (Scenario B) If H0 is true, the between and the within estimates will be approximately the same and F= If H0 is not true, the between group estimate tends to over-estimate a^2 and the between group estimate will be larger than the within estimates When H0 is not true, F > 1 When H0 is true, the F statistic has an F sampling distribution. The P value is the right-rail probability that the F statistic exceeds the observed F value. The larger the F statistic, the smaller the P value. EXAMPLE We expect F= 1 when H0 is true. F= 26 so there is strong evidence against the null, we can reject the null hypothesis of equal population means. WITHIN GROUP ESTIMATE VARIANCE It is a weighted average of the separate sample variances, with greater weight given to larger samples