Docsity

Statistica - BEMACC esame generale, Appunti di Statistica

Toggle sidebar
bg1
Statistics - BEMACC
general exam
Micro-data: collected on individuals, with these data we struggle more
Macro-data: collected on groups of individuals such as countries
Statistical unit: entity on which we run our measurements
Target population: the collection of all statistics units on which we might run our
measurements. We can have an ‘infinite population’ and this is the case where the
group of population we would like to work with is extremely big, at the point that we
cannot have as our scope to measure on each and every unit of the population. We
use N for the size of the population and we use n for a sample of population.
since we work with human beings, the first tool we are going to use to collect data is
going to be a questionnaire.
Secondary data: data collected by others that might be useful for our analysis.
Statistic as the science of
-Design and studies, for example secondary data that are part of a design that is not
ours.
-Analyzing collected data
-Translating data into knowledge so to make decisions and predictions
What is the point?
Using the sample to learn about the entire population, this is an inferential process.
My sample is going to be representative for the population so should be a good
picture, a good scale of the population. The unique way to end out with a sample
which is representative of a population is by using a random sampling, so the units
must be drawn randomly, and the language related to random samples is probability.
We have some characteristics, firs of all the parameters that are numbers that
provides us with a summary of the behavior of the characteristic of the population ( =
numerical summary at population level). The mean (arithmetic average) of the
number of tickets bought in our population level is a parameter, is called statistic and
this is a constant that we are not able to know because our population is infinite. So a
statistic is a numerical summary at sample level. Then the observed value of the
sample mean /statistic will be used to approx the population or sample.
Descriptive statistic: learn to do a good statistic using sample statistics
Statistical variable: is the result of our measurement process, it is not the
characteristic we are interested in, but the way this characteristic was measured. Can
be:
• Categorical - not numbers
• Nominal - no ranking of its levels
(values)
• Ordinal - we can rank its levels
• Numerical
• Discrete - is a variable that whenever
you consider any two possible
values, the variable cannot take any
value within
1 di 27
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b

Anteprima parziale del testo

Scarica Statistica - BEMACC esame generale e più Appunti in PDF di Statistica solo su Docsity!

Statistics - BEMACC

general exam

Micro-data: collected on individuals, with these data we struggle more

Macro-data: collected on groups of individuals such as countries

Statistical unit: entity on which we run our measurements

Target population: the collection of all statistics units on which we might run our

measurements. We can have an ‘infinite population’ and this is the case where the

group of population we would like to work with is extremely big, at the point that we

cannot have as our scope to measure on each and every unit of the population. We

use N for the size of the population and we use n for a sample of population.

since we work with human beings, the first tool we are going to use to collect data is

going to be a questionnaire.

Secondary data: data collected by others that might be useful for our analysis.

Statistic as the science of

  • Design and studies, for example secondary data that are part of a design that is not

ours.

  • Analyzing collected data
  • Translating data into knowledge so to make decisions and predictions

What is the point?

Using the sample to learn about the entire population, this is an inferential process.

My sample is going to be representative for the population so should be a good

picture, a good scale of the population. The unique way to end out with a sample

which is representative of a population is by using a random sampling, so the units

must be drawn randomly, and the language related to random samples is probability.

We have some characteristics, firs of all the parameters that are numbers that

provides us with a summary of the behavior of the characteristic of the population ( =

numerical summary at population level ). The mean (arithmetic average) of the

number of tickets bought in our population level is a parameter, is called statistic and

this is a constant that we are not able to know because our population is infinite. So a

statistic is a numerical summary at sample level. Then the observed value of the

sample mean /statistic will be used to approx the population or sample.

Descriptive statistic: learn to do a good statistic using sample statistics

Statistical variable: is the result of our measurement process, it is not the

characteristic we are interested in, but the way this characteristic was measured. Can

be:

  • Categorical - not numbers
    • Nominal - no ranking of its levels

(values)

  • Ordinal - we can rank its levels
  • Numerical
  • Discrete - is a variable that whenever

you consider any two possible

values, the variable cannot take any

value within

  • Continuous - comes up from a measurement process and when we consider any

two values, the variable will take a value in between

Why making this distinction? I cannot use any statistical tool for any variable, I need to

classify my variable to use the right tools.

I can decide to attach labels to variables (ex. 1 for a yes answer and 3 for a no

answer). It is important also the question that I make because is that which sets our

variable.

General social survey (GSS) - every 2 years the same set of questions is asked to

individuals drawn randomly, each round of the same survey generates a data set that

is called cross section. (If I have same questions but different people, but selected …

panel )

GSS of 2012

We start always from univariate descriptive (describing 1 variable at time, different

descriptions for different variables)

Best description - few distinct tables (1st column)

We prefer to work with relative frequency, I look at the frequency, convert it in %, look

for the highest value, I could also make a chart: pie or bar chart. We need to look for

the best charts because are those that convey information and we should know how to

read them.

Then I can build a frequency distribution table but before I group values into intervals.

  • intervals with the same length, how many?
  • intervals with the same width, bounds position?

So first of all I have to decide how many intervals I need. Through this process I have

my first loss of information because I decide the number of intervals and if I set a less

number intervals than I should I will probably loose info, while if my number of

intervals is bigger number of intervals I will end up with empty intervals.

Histograms

  • Horizon axis - intervals
  • Vertical axis - height of the bar, density (relative frequency / interval length)
  • Bar
    • Area equal to the interval’s relative frequency

We prefer density to relative frequency because ..

What does it mean to measure the central tendency of a variable? I want to replace

the entire set of info based on 1 level so I will condense data in one value ( loose a lot

of info )

  • Mode is the level or value that we observe with highest frequency
  • Median is the observed value that finds in the exact center between all the values.
    • rank the observations
    • n odd value —> with position (n+1)/
    • n even value —>
      • Two middle observations I cane make the mathematical average but only if the

value is numerical, but I want the median to be an observed value and with the

average I cannot.

  • We might take any of the two

Measure of the central tendency = extreme summary of the sample behavior of our

variable so a brief summary of what’s happening.

  • Median
  • Upper quartile
  • Maximum

Boxplot is a graph made up by 2 pieces: a box and

two segments. Lower edge = lower quartile, upper

edge = upper quartile, in the middle we have the

median.

IR = Q3 - Q

IR * 1.5 —> Q1 - 1.5*IR

a. min > Q1 - 1.5*IR

b. min < Q1 - 1.5*IR

if the min is greater than Q1 - lower*1.5 —> lower wicker will join lower quartile to the

minimum, while if the minimum is smaller we are dealing with an outlier and we

should draw our whisker from the value to

the values falling below the quartile represented with symbols that

could be circles, stars, everything are the outliers. So the rule says

that the outlier is any value facing below or above the lower

quartile by more than 1.5*IR (interquartile range).

Measuring the variability :

If we are not given the histogram, but just the mean we can say

that two collection of data re the same, but they aren’t —> these

two graphs have the same mean, but they are different for

example we see here that in Denmark the features are more

homogeneous than in USA.

The range is a first measure that classifies minimum and

maximum, the second measure is interquartile range (difference between upper and

lower quartile), measures the interval in which I have the 50% central part. To find the

box with higher variability we have to compare the height of the box.

Deviation (value - mean), if falls before the mean is negative

while if after is positive.

Variance (s^2), I square it to have positive values and to

emphasize the distance from the mean when needed. Are we measuring variability?

Yes because when we are given a variance (always positive and = 0 when all the

values are the same so equal to the mean) the greater the distance from 0 the greater

variability, but also is measures how much the observations are scattered around the

mean, taken as reference point.

The standard variation is s (= s^2 but under square root) and we prefer work with the

standard variation instead of the variance.

Te variance measures variability with respect to the mean so measures the

spread of our value with respect to the mean so if two … have different

means we cannot compare them using the standard variation/variance.

Coefficient variation is the standard deviation expressed as a percentage of the mean:

SHAPE

Only numerical variables are considered, and the shape assessed is either based on

the histogram or boxplot.

Shape form histogram

Whether the distribution is approximately symmetric, before the center is a mirror of

the side after the center. If the histogram is asymmetric, on the other way, some

distinctions have to be made. The measure taken to assess symmetry takes:

  • 0 if symmetric
  • Positive number >
  • Negative number >

SYMMETRIC DISTRIBUTIONS

  • Bell shaped > moving in ascending order the density increases until

the peak (maximum), and then decreases

  • Not bell shaped (or U shaped) > high density on low values and high

values, and low density on the center ones.

In case of a symmetric distribution, the center is both median and

mean.

What about the corresponding box plots?

  • The distance between median and lower quartile is exactly equal

to the distance between median and upper quartile.

  • The distance between Q1 and minimum is equal to the distance

between Q3 and maximum.

What is going to change between bell shaped and U shaped?

The width of the box with respect to the length of the whiskers.

In the bell shaped, it takes some time to reach the lower quartile from the minimum.

What happens below the box (whisker + outliers) turns out to be greater than the

distance between the lower quartile and the median.

(median - Q1 > Q1 - minimum)

In the U shaped, the main difference is that starting from the minimum,

the lower quartile is reached faster (due to having huge masses), while

reaching the median and the upper quartile takes more time.

Skewed-right distribution

High frequency of low values and then gradually decreasing.

Is the median in the middle? No, it' closer to the lower quartile

In the boxplot, the minimum is not expected to be an outlier thus the

distance between lower quartile and minimum is smaller than the

distance between the one between the upper quartile and the maximum.

Is mean = median? No, the mean is greater.

The variability pulls up the value of the mean, that falls on the right of the median.

Skewed-left distribution

The distance between minimum and lower quartile is bigger than the

one between upper quartile and maximum. Relationship between and

median is that the mean is smaller than the median (that is not in the

middle, also in this case). There are low masses on low values, it takes

some time to reach the upper quartile from the minimum.

Concentration analysis

With this we deal with a characteristic of relative frequency, but under a different

perspective.

" Top " and " bottom " are typical words of this kind of analysis: the top is the

percentile of which you observe the greatest data , the bottom is the percentile

on which toy observe the lowest data.

Is the total variable's amount equally shared among the units of the sample?

In this kind of analysis there are some extreme situations:

  • Perfect equality ( each person is going to have the mean of the variabl
  • Maximum concentration ( one single person is going to have the total amount of

the variable, while the other don't have anything)

We need now to asses in which of the two extreme situations the observed value is.

  • Question 6

we are given the concentration curve the black (that is always convex, below the

bisector and the lower it is to the bisector the lower is the concentration). The

concentration index is equal to 1? No bc we don’t have a perfect concentration,

equal to 2? False because concentration index always between 0 and 1.

We know that n = 80, then (0.5 ; 0.2) —> 0.5 = F and 0.2 = Q

—> I know that 20% of total sales is held by bottom 50% of units.

—> I know that 80% of total sales is allocated to top 50% of companies.

There is another point that I know has the position of (0.9875 ; 0.59)

—> I know that 41% of total sales is allocated to top (1-0.9875) 100% = 1.25% of

companies.

% of total sales : 1/80 is a top, one unit over 80, the maximum = 1.25%, this is the

proportion of units that is associated with one unit (the same would work for the

lowest value because is still 1 out of 80). —> answer B.

  • Question 8

top 5% has 30% of total amount —> coordinates: (0.95 ; 0.7)

bottom 30% has 5% of total amount —> coordinates: (0.

answer c wrong, genii’s index is not equal to zero because to

have it equal to zero I need F = Q, also d is wrong because to

have gina’s index = 1 I would need at least Q or F equal to

zero so the right answer is e, non of the above.

  • Question 10

here we are given the 5 number summary: min = 10, Q1 =

30, median = 40 , Q3 = 60 and max = 110.

c- “On 50% of the sample units the variable takes a value between 30 and 60” from

the median I can say that on 50% of units I observe a value <= 40, then I know that

above 60 I have a 25% and below 30 I will have another 50% so it is true because

between 30 and 60 I have a 50%.

d- “On 25% of the sample units the variable takes on value smaller than or equal to

30 ”, true because 30 is the lower quartile.

e- “The minimum is an outlier and the maximum is not an outlier”, I know that IR =

60 - 30 = 30 then I do 1.5*30=45, 30-45 = -14 < 10 , the minimum falls in so is not

an outlier I do the same for the maximum so 60 + 45 = 105 < 110 the max is an

outlier.

  • Question 9

min = 0, Q1 = 251, median = 371, Q3 = 533, max = 1000

detection of shape: median - Q1 = 371 - 251 = 120 Q3 - median = 533 - 371 =

162 the first is not equal to the second —> is not symmetric.

I have Q1 - min = 251-0=251 max - Q3 = 1000-533=467, 467>251 so I know

that this variable is right - skewed —> mean > median.

Detection of outliers: IR = 533 - 251 = 281, then IR * 1.5 = 282*1.5 = 423 min is not

outlier, then 533+423 maximum is an outlier.

Aim of bivariate descriptions :

In our approach we say that a given characteristic might be explained by another

characteristic and this will asses if I am wrong or not. The second statement is that I

have to measure the 2 characteristic that I want to explain and I generate a variable,

the two are connected because there is association between the two variables.

Dependent variable - measures what we want to explain

Independent variable - what we suggest as providing an explanation

With the coordinates the

first refers to the bottom so

if I have that the top 3%

holds the 40% I know that

the bottom 97% will hold

the 60% so my coordinates

are going to be: (0.97 ;

Three cases:

  1. Both dependent and independent variables —> categorical
  2. Dependent variable —> numerical , independent variable —>

categorical

  1. Both dependent and independent variable —> numerical

Case 1 - in a study case that monitored foods for pesticides residues,

26698 foods is the sample units, they had two variables:

  • food type —> organic/conventional
  • pesticides status —> presence or not of pesticides

Now I have to assess if the presence of the pesticides

depends on the food type or not so if the second

variable depends on the first one or not. We start from

the cross tab or contingency table, this delivers the joint

description of the behavior of the two variables.

29 is the n of units on which I find jointly the value

organic and presence, 98 are organic and not pesticide.

The last column delivers the marginal distribution of the

variable food type. The last row is the marginal

univariate distribution of pesticide status.

I can do the same work with the relative frequency so 0.001 is the proportion of food

which is both organic and present. Is important to say that we are

not assessing causality , so we cannot say that one thing is the

cause of the other, I just try to find the association, dependency.

How do i find association?

  • Comparison , we start from the independent variable (with R)

and base on this I split the sample in 2 groups , the two variables

are organic conventional, now separately we describe the behavior of the

dependent variables separately. Given the value conventional for the dependent

value and the organic for the independent value.

This table delivers relative frequency, called conditional relative frequency

distribution of pesticide status given value organic for food.

—> Being a conventional or organic food matters!

Why I always work with relative frequency distribution that

are conditional? Why I work out the conditional relative

frequency and not just compare the joint counts? I always

workout the relative frequency , is the only way I can

account the differences in sizes.

My chart is going to be a bar chart, 2 types:

  • Stacked bar : X-axis the two .. organic and conventional,

the hight of the bar is devoted in present and non present

  • Side by side bar : is similar, but visually different

Case 3 - when the two variables are both dependent.

Is there association between the number of hours spent watching tv (h) and gender?

To find association I have to assess when tv hours behaves differently in the 2 groups.

I have a dependent variable (tv h) categorical —> I use the relative

frequency distribution , but since the variable is categorical I have

more ways to describe it:

  • I can work out the means of hours for male and female and then

compare the results.

  • I might then derive a box-lot (with 5 number summary)

8 di 27

Males:

  • mean = 2811
  • s = 2523

Females:

  • mean = 3.
  • s = 2622

Now from my dependent variable I take a level at the time and compare it with the

relative frequency. The values are so different and this means that there is

association, because they do not behave in the same way. “Report the percentage of

responders that in the group of self employed used public transports” = 30%.

To ask R to divide groups base on transport I write:

Question 5

This question is an indirect way to ask us the shape, the

relation between mean and median is related to the graph:

symmetric = close, right-skewed mean > median, vcvs.

Is it symmetric? No, actually is right-skewed.

Is the average mark symmetric? Approximately symmetric

bell shaped (draw 2 lines, above 22 and 26, in between I

have a lot of points while outside the frequency diminishes

—> bell shaped)

So a. wrong because if study time right skewed I cannot say

that the mean is smaller than the median, is the opposite b. the ranges are not similar

(y: 22-26, x: 50-75), c. If I had to draw a line I would do it with a positive slope, d.

Maybe there is a weak correlation, but not so weak to be zero. So answer is e.

Question 7

Pearson correlation index measures weather the linear association is strong or weak,

is a relative index and takes values between -1 and 1 —> a. 2.5 no too big, b. -0.77 No

the line has positive slope and same works for e, d. 0.08 we have a strong relation and

this number is too low —> answer is c.

Question 9

I create with R a table with joint count, we count the sizes of the group so the party

and the gender; then I create the object tab2 to store my data and computations. A. ‘If

we restrict our attention to the group of women 13240 report to be

Democrat.’ True, i made my table. b. out of males are republicans

approximately 29% with the prop.table(tab2,2) which is the table

with joint relative frequency, I see that yes is true. c. Same for

female democrats, true.

Question 8

Can we claim that the attending graduate or undergraduate curse

has an impact on the time connected on Facebook? No because

min almost the same, Q3 very close, mean very similar —> the two

groups are very similar —> no association.

Question 10

It’s c

Probability

Probability is in our everyday life, because we live taking decisions in an uncertainty

environment. So probability is the mathematical language to uncertainty. We need the

language if probability in statistics whenever we want to run inferences and from the

analysis of the samples we want to learn from the population.

Random variable , in probability we always have a random experiment which is a

process that has an uncertain outcome (ex. toss of a coin with 2 possible outcomes).

So I select at random an individual, before selecting it I can ask my question (are you

foreign?), after I did my experiment I will know if I was right.

We might have outcomes that are numbers or not.

When I make a joint relative

frequency (tab1,2) where I

identify with 2 my independent

variable I am asking a table

where I see the percentage of

the dependent variable in the

independent (% of democrats

in females) while with (tab1,1)

the opposite so % of females

Random variable = function that associate with an experiment’s outcome a

number. For example when I toss 2 coins I can have 3 variables: 0 if no heads, 1 if

one head and 2 if both are head. And the number that comes out is going to be my

observed value.

There are two kind of variables:

  1. Discrete random, countable, finite set, whenever I take two values

my variable can take only the two values

  1. Continuous random, uncountable, infinite set, whenever I take two

values may variable can take any value in between (ex. Hour I

walk in a day, can be one, two or 1,5)

Discrete random variable

We are looking for a way to compute the probabilities of observing

outcomes/values within specific intervals. The way we

describe the probabilistic behavior depends on the kind of

variable: for discrete random variables we use the

probability mass function.

Pr(X,x1) = pi for i = 1,2,..k

This function associates with each of the distinct values

the probability to observe them. It assigns masses of

probability to distinct values. The values of probabilities

must be >= 0 and the sum of probabilities must be = 1.

The probability functions are summed to be known, for

now.

Whenever we're given the probability mass function

The expected value is a mean and has the same properties and definition of the

expected mean (from stats not probability).

In probability we use Greek letters to denote stuff: in this case the notation of the

mean is μ.

The variance on the other hand takes the name σ.

Continuous random variable

Its probabilistic behavior is described by the density function, that has a specific

characterization:

  • It must not be negative
  • The area of the region delimited by the graph of the function if the x - axis = 1

This area is by definition the area of the plane delimited by the function, so the

probability is an area.

We will never be asked to compute probability from density functions, we must

however retain the idea that probability is an area. Whether we include or not the

bounds does not affect at all the probability. In a continuous setting, the probability to

observe a specific value is always 0.

Quantile of order 1 - α

Let α be a number between 0 and 1. Both α and 1 - α can be a probability (as both are

between 0 and 1). We define the quartile of order 1 - α, for a given α, the value such

that I have a probability equal to 1 - α to observe a smaller value, and a probability

equal to α to observe a greater one. The notation is q α.

Graphically, the probability below it's the region of the graph between 0 and the value

we're considering. The quantile is a number that we look for on the x axis.

Lecture 8 part 1

Question 8

“The random variable X approximately has lower quartile 10 and upper quartile 20.

Select out of the following the correct distribution for X” —> Q1 = 10 , Q3 = 20.

Answer d:

‘Bernoulli with success probability 0.5’, can it be the case? Bernoulli is a discrete

random variable that takes only two variables, can my variable with this two quartiles

be a Bernoulli? Q1 = 10 = Pr(x <= 10 ) = 0.25, but with a Bernoulli that takes only two

variables this is impossible. The other answers all say that my variable is normal, a:

mean 10 and sd 7.4 that’s because in a normal distribution which is symmetric. The

mean is also the median so 10 cannot be the expected value because is … b: normal

with mean 20 not possible because the upper quartile is 20, c: mean 15 and sd 7.4,

this is right because the distribution is symmetric —> median in the middle exactly

and the mean coincides —> 15 and answer e is definitely not the case with mean

(above the upper quartile).

Discrete bivariate vector

X - discrete random var with values x1,x2..xk

Y - discrete random var with values y1,y2..yk

Marginal probability functions

  • Prx (X, xi) for i = 1,2,..k
  • Pry (Y, yj) for j = 1,2,..h

For any pair of values x and y the joint probability can be

obtained and is the product of the two marginal probability. Two

variables are independent when the conditional distributions are the same.

The expected value is linear, the variance no and the total uncertainty is

given by the sum

Question 6

“Consider two random variables X and Y and let T =X-Y. Select the wrong statement.”

a. The variance of t cannot be negative true.

b. the expected value of t can be negative, true I don’t know, maybe expected value

of y > than the one of x.

c. ‘The variance of T when the value of the Pearson's correlation coefficient between

X and Y is positive, is greater than the variance in the case of a negative Pearson's

correlation index.’ If the covariance is negative multiplied by another negative the

total varianceis going to be positive and in the other case, if row is positive, the

covariance is positive —> the total variance would be negative. Wrong

d. ‘The expected value of T when the value of the Pearson's correlation coefficient

between X and Y is positive, is equal to the expected value of T in the case of a

negative Pearson's correlation index.’ True because the person correlation doesn’t

enter the … value of t

e. 'If the covariance between X and Y is

positive also Pearson’s correlation

coefficient is positive.’ Yes because the

sign of the correlation coefficient is the

Sogn of the covariance

Question 9

These two are both discrete and binary,

a. E(X) = E(Y), so is the E(Y) = 0.5?

b. Has a Bernoulli distribution

c. V(X) = V(Y), they gave the sane expected value, but x

takes the value of 0 or 1 , y takes the values of -

or 11 —> we expect the variance of y to be greater

than the variance of x.

d. X and Y are independent. For each cell we should need

that Pr (x = y = -10) = pr (x=0)Pr(y = -10) = 0.5 *0.5 =

0.25 , they are independent, true

e. The probability that Y = 11 is 0.

Ex. I’m going to buy milk, biscuits, bread, I don’t know the price for each item of the

basket, the total expense is a random value and the expected total value is going to

be the sum of each expected value. The variance of the total is going to be given by

the variance of each

If we take n number variables and compute their average, the variability of their

average is going to be smaller than the variability of each one

Central limit theorem :

Take n number variable that needs to be independent and identically distributed —>

E(x1) = μ and Var(x1) = σ2.

Consider T as their sum, with respect to T we already know that E(T) = nμ and Var(T)

= nσ2.

For large n we prove that the distribution of T (probabilistic behavior) can

be approximated by a normal N(nμ, nσ2)

This theorem holds also for a large n X bar.

Question 1

'Car drivers who refuel in a motorway in 70% of cases choose a self-service pump.

Consider 80 refuels randomly selected' —> It is value 1 when we use a self service,

while 0 when we don’t use the self service, and I have a Pr(x=1) = 0.7 & Pr(x=0) =

0.3. since it is a Bernoulli the E(Xi) = 0.7 and Var(Xi) = p(1-p) = 0.7*0.3= p. I know I

am going to use the central limit theorem

a. Report the distribution of the number of self-service refuels out of the considered

  1. Is it an exact or an approximate distribution?

b. Report the probability that at least 60% out of the considered 80 refuels are self-

service.

c. Report the expected number of refuels out of the considered 80, which are not

self-service

We don’t know the exact distribution of T, but the approximated one because due to

the central limit theorem it can be approximated by a normal E(T) = 80*0.7 = 56

var(T) = 800.70.3 —> the distribution of T can be approximated by a normal

distribution with expected value 56 and a variance of

T is the count, absolute frequency I observe out of 80 the drivers using self-service. I

can use the central limit theorem because n is large, = 80 so I use the normal:

N(800.7= 56, 800.7*0.5 = 16.8) —> T is the total number of drivers using a self

pump. I know that bar X = T/80 = P (proportion) which is a mean

b. Whenever we are asked to compute a probability I have two ways: 48 out of 80 are

done service (Pr (T>= 48)) or I can write it with the proportion: drivers using self

service is at least 0.

(Pr (P >=0.6) = 1 - Pr (P<0.6) = 1- pnorm(o.6,0.7,sqrt(0.3*0.7/80)

s/sqrt(n) = 5/ sqrt(30) estimate of standard errori of the mean (σ/sqrt(n))

A confidence interval is always specified, always comes along, we work it out it refers

to the confidence level which is (1 - alfa)100% alfa very

small (1-alfa ~ 1)

Usually alfa = 0.01, 0.05, 0.1 so the typical levels of confidence are 95%, 90% and

So the smallest value alfa takes, the higher is my confidence. The lengths of the

confidence intervals provides us the accuracy, the shorter, the more accurate.

Two cases:

  1. Normal population with known variance: (X1…xn) iid N(μ ,σ2) σ2 = 3

I know about the sample mean that: E(X barred) = μ , var(x barred) = σ2/n

known the sum of 2 normal random variables is a random variable

standardization of the sample mean = (x barred - μ) / σ/sqrt(n) —> the

distribution is a standard normal ~ N(0,1)

The confidence interval is obtained by adding and subtracting the same quantity

(margin of error) standard error (σ/sqrt(n)) *

The greater the confidence, the wider the interval.

  1. Normal population unknown variance: N(μ,σ2), barred x = μ s^2 = σ

5/sqrt(n) —> σ / sqrt(n) SE of the mean x barred ~ N(μ ,σ2/n)

(X barred - μ) / s/sqrt(n) this holds only if at the top we have a normality

assumption.

This is the student’s T distribution, we use it when σ2 is unknown.

Exercise session 5: case 1 or 2?

  1. Normal with variance of 225 so case 1.

X ~ N(μ ,σ2=225) n = 50 x barred = 150

99% —> 1-2 = 0.99, alfa = 0.

#interval: [x barred - (Z0.01/2)sigma / sqrt(n) ; x barred + (Z0.01/2)

sigma/sqrt(n)]

#Z0.01/2 —> quantile of N(0,1) of order 1- (0.01/2)

#on R studio: qnorm(1 - 0.01/2) = (144.527 , 155.474)

in our 99% confidence only on the 1% of cases I expect to be outside

of interval.

The length of the confidence interval is (2Zalfa/2)sigma / sqrt(n)

(2Zalfa/2)3 / sqrt(n)

  1. Normal, probabilistic part, 34 no variance given, is unknown.

(a and b did yesterday), n = 30 x barred = 34, s = 5

1-2 = 0.9 2 = 0-1 take the estimate and subtract the margin of

error:

x barred - t(n-1) *s/sqrt(n) ; x barred + t(n-1) *s/sqrt(n)

x barred +- t(n-1) *s/sqrt(n)

(34 - t(29) * (0.1/2) * 5/sqrt(30 , 34 + t(29) *(0.1/2) *

5/sqrt(30))

The length of the confidence interval is 2t(n-1), alfa/2 *s/sqrt(n)

  1. Normal (probabilistic assumption statement) , X ~ N(μ ,σ^2=3^2) n = 16

x barred = 17

a. The 90% confidence interval on the population mean time spent on the web site

has midpoint 17 and is worked out using the quantile of order 0.95 of the

standard normal distribution. True

quantile of

order 1-alfa/

of Students

with n - 1 =

degrees)

qt(1-0.1/2 ,

b. The standard error of the estimate of the mean time spent on the web site is

0.75. the SE is sigma/sqrt(n), = 3 /sqrt/16) = 0.75, True

c. If we add 10 more observations to our sample, we cannot say

whether the length of the 99% confidence interval worked out

on the new sample is smaller, greater or equal to the length

of the 99% confidence interval on the original sample of size

  1. False because the length here is … and is going to

decrease

d. If we add 10 more observations to our sample, the margin of

error of the 99% confidence interval worked out on the new

sample is smaller than the margin of error of the 99%

confidence interval on the original sample of size 16. True

e. The estimator of the mean time spent on the web site has a

normal distribution. True, the distribution (of the sample mean9ì) is x barred ~

N(μ ,σ2/n = 9/16)

  1. Second case, point b with R I use: t.test(folder$table, conf.level = 0.90)

Lecture 11 - asymptotic confidence intervals

Whenever we are given an estimator we should look at the properties,

Estimate - margin of error = estimate - quantile (1-alfa /2) * SE, this SE can be given

or we do an estimate.

So if I am given the estimate median and the standard error of the estimate median I

can find

the ..

Normality assumptions when n is small so with small sample sizes.

Mock exam - without R

  1. We have twi variables and is asked the % of people that operate in north Italy, here

we are asked for the computation of a conditional relative frequency (conditional

because are restricting the attention ‘in the group of firms in Italy’). This is a

conditional relative frequency to be computed (quad)

  1. Then we have the 5 number summary, so ask for outliers, skewness, relationship

between mean and median

  1. Concentration curve (no concentration analysis with R)
  2. Data and synthetic measures are give, plain computation
  3. This is not inference because we have mean, standard deviation or median, is

probability

  1. Inferential statistic
  2. Inf. statistic

Mock exam - with R

  1. From the box plot I se that the ..point a. We have the central limit theorem or the

Bernoulli, in this case is the second one, were know that n is large enough-

Hypothesis testing

The estimation problem is the need to approximate μ, so we use a tool known as

estimator (that must be the best one so it must be unbiased and consistent).

An hypothesis is any statement on a population parameter, claims that: The unknown

parameter takes a value in range of values and has a specific value.

We are never going to be able to test whether any statement is true or false, the only

way is to investigate at the level of the population but this is not feasible.

Are we going to deal with any kind of hypothesis? No, there are two kinds:

  • Simple hypothesis > specifies one single value of the parameter

SE = standard deviation of sample mean.

Test statistic = function of the sample that summarizes the info of the

sample that tells us if reject or not the sample.

P-value = probability of observing a value of the test statistic more

extreme than the observed one. This has to be competed presuming true

the null hypothesis (H 0 ).

The p value also quantifies the amount of evidence that I have against the hypothesis

—> I reject if the p-value is smaller than the significance level (alpha).

Normal population, known and unknown variance

When we have mi zero in the formula we assume that it is standard normal, N(0,1).

  • Estimator must be unbiased, to apply the central limit theorem must be also large

enough.

  • Confidence interval: t = SE * quantile and this is the

accuracy of my estimation

  • (Estimator - value specified under the null hypothesis (H 0 )) /

SE = (T - theta zero ) / SE

  • If theta = theta zero —> known distribution ( large n —> N

Probabilistic framework

If the variable has the same variance in the two groups

considered we could start from a comparison of the two means and if they are similar

= no association, while if they are very different there is association.

Now I take two different groups where the population is a group of people over 18 that

live in the US, and I compare them. First I make a box plot, different range, same max,

there are outliers, but no similar behavior —> there is association.

Now mean:

  • high school greatest level —> 3.197 observed sample mean and 2.643 observed

standard deviation

  • No high school degree —> observed sample 2.736 mean and 2.491 observed

standard deviation

Not close enough —> there is association

Now I assess association through means comparison ( variance = ), now I draw one

individual at random from the population with high school and ask how many hours he

watches tv and do the same with the other group and the answer of this question is

going to depend on the individual and I assume is greater than zero.

Pop 1 properties of the estimator: is a good estimator, E ( x barred) = mi x

Mi y is the average number of tv hours not at the level of the population, but of a

single individual drawn at random from pop 2.

Now we have a new parameter which is mi x - mi y , I have to estimate it.

Now I have to check if this is a good estimator , if it is unbiased and to know I have

to check if its expected value = parameter I am estimating —> E ( x bar - y

bar ) =? mi x - mi y.

Now I check the variance of my estimator and see if is consistent (it is).

Then go find the SE

If we assume that both X and Y are normal, then also bar x and bar y are normal

then also (bar x - bar y) has a normal distribution

Equal population variances but I need to estimate this sigma squared because I don’t

know its value and assuming variance is the same doesn’t mean that also the

estimator is the same.

Test statistic = measure of distance between

my estimate (diff of the 2 sample mean here)

and zero.

Exercise by us:

Xi ≈ N(mi, sigma squared) H 0 mi = 3

H 1 mi > 3

a. T ≈ N(0,1)

b. T ≈ students T with 19 degrees of freedom

c. T ≈ students T with 20 degrees of freedom

d. T ≈ students T with 19 degrees of freedom if

mi>

e. None

b would be correct if provided that the null hypothesis is true, but no so its a.

Independence test

Dummy high —> categorical nominal

News recorded —> nominal

We always start the description of a joint behavior of the two variables using the cross

tab with joint count (given relative frequencies).

Random variable x, level of education? Highest school 0, bit high school 1

Now again adding another question, how often do you read newspaper? Everyday 1,

once a week 2, less than once a week 3. This info come from the table of joint counts.

Is it enough info to presume there is association between level of high school and

reading newspaper?

Chi-square test

H 0 —> var x and y are independent, if true we presume

H 1 —> var x and y are not independent

Two variables are independent when their joint probability (prob to observe two

specific values) so in this case the joint probability is to gave attended high school and

reading newspaper every day

X and y inde when: Pr ( x = xi , y = yi) = Pr (x = xi) Pr (y = yi).

Then if the two variables are independent this probability must be equal. This is what I

presume under the null hypothesis. While if I’m under H1 : Pr ( x = xi , y = yi) != Pr (x

= xi) Pr (y = yi).

The value is the probability to observe a value of the test statistic more ‘extreme’, but

not the strength of the association while the significance level is the prob to do type l

error.

Test statistic

If the two variables are independent (under H0), we expect to observe ansi at the level

of the sample: Pr ( X = i , Y = j) = Pr (X = i) Pr (Y = j).

Absolute frequency (new notation):

  • Ri = assolute frequency (or count), we observe X equal to i —> Ri = n*FR(X = i)
  • Cj = totals for counts —> Cj = n*FR(Y = j)

Relationship of a perfect ideal association in terms of counts: (RiCj)/n*

While the expected count (Eij) = same formula as above

Whenever we reject —> there is enough empirical evidence to state that there is

association between the two variables.

The null hypothesis is a claim of independence

Here the test statistic compares the observed counts against the

expected counts

  • When we reject = there is

enough empirical evidence to

say that there is association

between the variables

  • The null hypothesis is a claim of

independence