Professional Documents
Culture Documents
Statistical
Inference
Assoc. Prof.
Amany E. Aly
Lecture 7: Statistical Inference
Chapter
Objectives
Theoretical
Distributions of
Observations
Simulations Assoc. Prof. Amany E. Aly
Department of Mathematics, Faculty of Science,
Helwan University, Ain Helwan, Cairo, Egypt.
20 / 3 / 2023
Lecture 7:
Statistical
Inference
Assoc. Prof.
Amany E. Aly
Chapter
Objectives
Theoretical
Distributions of
Observations
Simulations
Lecture 7:
Statistical
Inference
Assoc. Prof.
Amany E. Aly
Chapter
Objectives
Theoretical
Distributions of
1 Chapter Objectives
Observations
Simulations Theoretical Distributions of Observations
Simulations
Lecture 7:
Statistical
Inference
Assoc. Prof.
Amany E. Aly
Chapter
After completing this chapter, you should be able to:
Objectives
Theoretical
Distributions of
Observations
Simulations
Lecture 7:
Statistical
Inference
Assoc. Prof.
Amany E. Aly
Chapter
After completing this chapter, you should be able to:
Objectives
Theoretical 1 Define key terms that are associated with inferential statistics.
Distributions of
Observations
Simulations
Lecture 7:
Statistical
Inference
Assoc. Prof.
Amany E. Aly
Chapter
After completing this chapter, you should be able to:
Objectives
Theoretical 1 Define key terms that are associated with inferential statistics.
Distributions of
Observations
Simulations
2 Recognize the variables of the ”cars.csv” data frame.
Lecture 7:
Statistical
Inference
Assoc. Prof.
Amany E. Aly
Chapter
After completing this chapter, you should be able to:
Objectives
Theoretical 1 Define key terms that are associated with inferential statistics.
Distributions of
Observations
Simulations
2 Recognize the variables of the ”cars.csv” data frame.
Assoc. Prof.
Amany E. Aly
Chapter The following link contains the adopted reference and all required
Objectives
Theoretical
Distributions of
data:
Observations
Simulations
Assoc. Prof.
Amany E. Aly
Chapter
1 Statistical inference is applied to data in order to address spe-
Objectives
Theoretical cific research question.
Distributions of
Observations
Simulations
Assoc. Prof.
Amany E. Aly
Chapter
1 Statistical inference is applied to data in order to address spe-
Objectives
Theoretical cific research question.
Distributions of
Observations
Simulations 2 We will demonstrate different inferential procedures using a
specific data set with the aim of making the discussion of the
different procedures more concrete.
Assoc. Prof.
Amany E. Aly
Example 1
Chapter
Objectives
Theoretical
read the content of the CSV file into an R data frame and produce
Distributions of
Observations
Simulations
a brief summary.
Assoc. Prof.
Amany E. Aly
Example 1
Chapter
Objectives
Theoretical
read the content of the CSV file into an R data frame and produce
Distributions of
Observations
Simulations
a brief summary.
> cars < − read.csv(”cars.csv”)
> summary(cars)
Lecture 7:
Statistical
Inference
Assoc. Prof.
Amany E. Aly
Chapter
Objectives
Theoretical
Distributions of
Observations
Simulations
Assoc. Prof.
Amany E. Aly
1 Binomial:
Chapter a The parameters that determine the distribution are n, the number of observations,
Objectives
Theoretical and p, the probability of obtaining the particular outcome in each observation.
Distributions of
Observations
Simulations
Assoc. Prof.
Amany E. Aly
1 Binomial:
Chapter a The parameters that determine the distribution are n, the number of observations,
Objectives
Theoretical and p, the probability of obtaining the particular outcome in each observation.
Distributions of
Observations b The expression Binomial(n, p) is used to mark the Binomial distribution.
Simulations
Assoc. Prof.
Amany E. Aly
1 Binomial:
Chapter a The parameters that determine the distribution are n, the number of observations,
Objectives
Theoretical and p, the probability of obtaining the particular outcome in each observation.
Distributions of
Observations b The expression Binomial(n, p) is used to mark the Binomial distribution.
Simulations
c The functions dbinom, pbinom, and qbinom may be used in order to compute
the probability, the cumulative probability, and the percentiles, respectively.
Assoc. Prof.
Amany E. Aly
1 Binomial:
Chapter a The parameters that determine the distribution are n, the number of observations,
Objectives
Theoretical and p, the probability of obtaining the particular outcome in each observation.
Distributions of
Observations b The expression Binomial(n, p) is used to mark the Binomial distribution.
Simulations
c The functions dbinom, pbinom, and qbinom may be used in order to compute
the probability, the cumulative probability, and the percentiles, respectively.
d The function rbinom can be used in order to simulate a random sample from this
distribution.
Assoc. Prof.
Amany E. Aly
2 Poisson:
Chapter a The parameter that determines the distribution is the expectation λ.
Objectives
Theoretical
Distributions of
Observations
Simulations
Assoc. Prof.
Amany E. Aly
2 Poisson:
Chapter a The parameter that determines the distribution is the expectation λ.
Objectives
Theoretical b The expression P oisson(λ) is used to mark the Poisson distribution.
Distributions of
Observations
Simulations
Assoc. Prof.
Amany E. Aly
2 Poisson:
Chapter a The parameter that determines the distribution is the expectation λ.
Objectives
Theoretical b The expression P oisson(λ) is used to mark the Poisson distribution.
Distributions of
Observations c The functions dpois, ppois, and qpois may be used in order to compute the
Simulations
probability, the cumulative probability, and the percentiles, respectively, for the
Poisson distribution.
Assoc. Prof.
Amany E. Aly
2 Poisson:
Chapter a The parameter that determines the distribution is the expectation λ.
Objectives
Theoretical b The expression P oisson(λ) is used to mark the Poisson distribution.
Distributions of
Observations c The functions dpois, ppois, and qpois may be used in order to compute the
Simulations
probability, the cumulative probability, and the percentiles, respectively, for the
Poisson distribution.
d The function rpois can be used in order to simulate a random sample from this
distribution.
Assoc. Prof.
Amany E. Aly
3 Uniform:
Chapter a The parameters that determine the distribution are a and b, the two end points
Objectives
Theoretical of the interval.
Distributions of
Observations
Simulations
Assoc. Prof.
Amany E. Aly
3 Uniform:
Chapter a The parameters that determine the distribution are a and b, the two end points
Objectives
Theoretical of the interval.
Distributions of
Observations b The expression U nif orm(a, b) is used to identify the Uniform distribution.
Simulations
Assoc. Prof.
Amany E. Aly
3 Uniform:
Chapter a The parameters that determine the distribution are a and b, the two end points
Objectives
Theoretical of the interval.
Distributions of
Observations b The expression U nif orm(a, b) is used to identify the Uniform distribution.
Simulations
c The functions dunif , punif , and qunif may be used in order to compute the
density, the cumulative probability, and the percentiles for the Uniform distribution.
Assoc. Prof.
Amany E. Aly
3 Uniform:
Chapter a The parameters that determine the distribution are a and b, the two end points
Objectives
Theoretical of the interval.
Distributions of
Observations b The expression U nif orm(a, b) is used to identify the Uniform distribution.
Simulations
c The functions dunif , punif , and qunif may be used in order to compute the
density, the cumulative probability, and the percentiles for the Uniform distribution.
d The function runif can be used in order to simulate a random sample from this
distribution.
Assoc. Prof.
Amany E. Aly
4 Exponential:
Chapter a The parameter that determines the distribution is the rate λ.
Objectives
Theoretical
Distributions of
Observations
Simulations
Assoc. Prof.
Amany E. Aly
4 Exponential:
Chapter a The parameter that determines the distribution is the rate λ.
Objectives
Theoretical b The expression Exponential(λ) is used to identify the Exponential distribution.
Distributions of
Observations
Simulations
Assoc. Prof.
Amany E. Aly
4 Exponential:
Chapter a The parameter that determines the distribution is the rate λ.
Objectives
Theoretical b The expression Exponential(λ) is used to identify the Exponential distribution.
Distributions of
Observations c The functions dexp, pexp, and qexp may be used in order to compute the density,
Simulations
the cumulative probability, and the percentiles, respectively, for the Exponential
distribution.
Assoc. Prof.
Amany E. Aly
4 Exponential:
Chapter a The parameter that determines the distribution is the rate λ.
Objectives
Theoretical b The expression Exponential(λ) is used to identify the Exponential distribution.
Distributions of
Observations c The functions dexp, pexp, and qexp may be used in order to compute the density,
Simulations
the cumulative probability, and the percentiles, respectively, for the Exponential
distribution.
d The function rexp can be used in order to simulate a random sample from this
distribution.
Assoc. Prof.
Amany E. Aly
5 Normal:
Chapter a The parameters that determine the distribution are the expectation µ and the
Objectives
Theoretical variance σ 2 .
Distributions of
Observations
Simulations
Assoc. Prof.
Amany E. Aly
5 Normal:
Chapter a The parameters that determine the distribution are the expectation µ and the
Objectives
Theoretical variance σ 2 .
Distributions of
Observations b The expression N ormal(µ, σ 2 ) is used to mark the Normal distribution.
Simulations
Assoc. Prof.
Amany E. Aly
5 Normal:
Chapter a The parameters that determine the distribution are the expectation µ and the
Objectives
Theoretical variance σ 2 .
Distributions of
Observations b The expression N ormal(µ, σ 2 ) is used to mark the Normal distribution.
Simulations
c The functions dnorm, pnorm, and qnorm may be used in order to compute the
density, the cumulative probability, and the percentiles for the Normal distribution.
Assoc. Prof.
Amany E. Aly
5 Normal:
Chapter a The parameters that determine the distribution are the expectation µ and the
Objectives
Theoretical variance σ 2 .
Distributions of
Observations b The expression N ormal(µ, σ 2 ) is used to mark the Normal distribution.
Simulations
c The functions dnorm, pnorm, and qnorm may be used in order to compute the
density, the cumulative probability, and the percentiles for the Normal distribution.
d The function rnorm can be used in order to simulate a random sample from this
distribution.
Lecture 7:
Statistical
Inference
Assoc. Prof.
Amany E. Aly
Chapter
One of the most problems of statistical inference is using the Nor-
Objectives
Theoretical
Distributions of
mal approximation for the sampling distribution of the statistic.
Observations
Simulations However, every now and then we may want to check the validity
of this approximation in order to reassure ourselves of its appro-
priateness.
Assoc. Prof.
Amany E. Aly
Chapter
Objectives Example 2
Theoretical
Distributions of
Observations
Simulations
Compute a simulation for the sample size of n = 201 and for
exponential distribution with parameter equal to λ = 1/12000.
Assoc. Prof.
Amany E. Aly > X.bar < − rep(0, 105 )
Chapter > f or(i in 1 : 105 )
Objectives
Theoretical
Distributions of
+{
Observations
Simulations +X < − rexp(201, 1/12000)
+X.bar[i] < − mean(X)
+}
> mean(abs(X.bar − 12000) <= 1.96 ∗ 0.0705 ∗ 12000)
Assoc. Prof.
Amany E. Aly The expression for generating a sample is rexp(201, 1/12000).
Chapter
Objectives
Theoretical
Distributions of
Observations
Simulations
Assoc. Prof.
Amany E. Aly The expression for generating a sample is rexp(201, 1/12000).
Chapter In the case where the simulated averages are stored in the
Objectives
Theoretical
Distributions of sequence X.bar then we may use the expression
Observations
Simulations
mean(abs(X.bar − 12000) <= 1.96 ∗ 0.0705 ∗ 12000).
Assoc. Prof.
Amany E. Aly The expression for generating a sample is rexp(201, 1/12000).
Chapter In the case where the simulated averages are stored in the
Objectives
Theoretical
Distributions of sequence X.bar then we may use the expression
Observations
Simulations
mean(abs(X.bar − 12000) <= 1.96 ∗ 0.0705 ∗ 12000).
In order to compute the relative frequency for the uniform
distribution U nif orm(3; 7), with sample size n = 100, use
the expression runif (100, 3, 7).
Assoc. Prof.
Amany E. Aly
Example 3
Chapter
Objectives
Theoretical
Carry out the simulation that produces an approximation of
Distributions of
Observations
Simulations the central region that contains 95% of the sampling distri-
bution of the mid-range statistic for the Uniform distribution,
U nif orm(3; 7):
+}
> quantile(mid.range, c(0.025, 0.975))
2.5% 97.5%
4.941680 5.059004
Assoc. Prof.
Amany E. Aly
Simulations can be used in order to compute the expectation,
Chapter
Objectives the standard deviation or any other numerical summary of the
Theoretical
Distributions of
Observations sampling distribution of a statistic.
Simulations
All one needs to do is compute the required summary for the
simulated sequence of statistic values and hence obtain an ap-
proximation of the required summary.
Assoc. Prof.
Example 4
Amany E. Aly
Obtain the expectation and the standard deviation of the
Chapter
Objectives mid-range statistic of a sample of 100 observations from the
Theoretical
Distributions of
Observations
Simulations
U nif orm(3, 7) distribution.
Assoc. Prof.
Example 4
Amany E. Aly
Obtain the expectation and the standard deviation of the
Chapter
Objectives mid-range statistic of a sample of 100 observations from the
Theoretical
Distributions of
Observations
Simulations
U nif orm(3, 7) distribution.
> mean(mid.range)
[1]5.000168
> sd(mid.range)
[1] 0.02767719
Assoc. Prof.
Amany E. Aly
Chapter
Objectives
The expectation of the statistic is obtained by the application
Theoretical
Distributions of
Observations
of the function mean to the sequence.
Simulations
Assoc. Prof.
Amany E. Aly
Chapter
Objectives
The expectation of the statistic is obtained by the application
Theoretical
Distributions of
Observations
of the function mean to the sequence.
Simulations
Chapter
Objectives
Theoretical
Distributions of
Observations
Simulations
Chapter
Objectives
Theoretical
Distributions of
Observations
Simulations
Assoc. Prof.
Amany E. Aly Hint:
Chapter
Objectives
Theoretical
Distributions of
Observations
Simulations
Assoc. Prof.
Amany E. Aly Hint:
Chapter
Objectives Notice that the first 29 patients received an active magnet and
Theoretical
Distributions of
Observations
the last 21 patients received an inactive placebo.
Simulations
Assoc. Prof.
Amany E. Aly Hint:
Chapter
Objectives Notice that the first 29 patients received an active magnet and
Theoretical
Distributions of
Observations
the last 21 patients received an inactive placebo.
Simulations
Assoc. Prof.
Amany E. Aly
4 > sd(magnets$change[1 : 29])
Chapter
Objectives [1] 3.236568
Theoretical
Distributions of
Observations > sd(magnets$change[30 : 50])
Simulations
[1] 1.578124
Assoc. Prof.
Amany E. Aly
4 > sd(magnets$change[1 : 29])
Chapter
Objectives [1] 3.236568
Theoretical
Distributions of
Observations > sd(magnets$change[30 : 50])
Simulations
[1] 1.578124
5 > boxplot(magnets$change[1 : 29])
> boxplot(magnets$change[30 : 50])
Assoc. Prof. tients that received an active magnet. There are no outliers
Amany E. Aly
in this plot.
Chapter
Objectives
Theoretical
Distributions of
Observations
Simulations
Assoc. Prof. tients that received an active magnet. There are no outliers
Amany E. Aly
in this plot.
Chapter
Objectives
Theoretical
5-b The second box-plot correspond to the sub-sequence of the
Distributions of
Observations
Simulations
patients that received aa inactive placebo. Three values, the
values 3, 4, and 5 are associated with outliers.
Assoc. Prof. tients that received an active magnet. There are no outliers
Amany E. Aly
in this plot.
Chapter
Objectives
Theoretical
5-b The second box-plot correspond to the sub-sequence of the
Distributions of
Observations
Simulations
patients that received aa inactive placebo. Three values, the
values 3, 4, and 5 are associated with outliers.
5-c To find the total number of observations that receive these
values:
> table(magnets$change[30 : 50])
0 1 2 3 4 5
11 5 1 1 2 1
Assoc. Prof. Amany E. Aly ( Department of Mathematics, Faculty ofLecture
Science,7: Helwan
Statistical
University,
InferenceAin Helwan, Cairo, Egypt.) 20 / 3 / 2023 28 / 29
Lecture 7:
Statistical
Inference
Assoc. Prof.
Amany E. Aly
Chapter
Objectives
Theoretical
Distributions of
H.W.
Observations
Simulations
Solve Question 9.2. page 155.