• Aucun résultat trouvé

3 Confidence interval of a probability

N/A
N/A
Protected

Academic year: 2022

Partager "3 Confidence interval of a probability"

Copied!
3
0
0

Texte intégral

(1)

Universit´e Joseph Fourier L2/STA230

Lab 5: Estimation and Confidence interval

Objectives: Compute estimator of an expectation or a standard deviation. Compute a confidence interval of a mean, a probability, a variance. Represent graphically that a confidence interval does not necessarily contain the true value. Represent graphically the convergence of a confidence interval when the length of the sample increases.

1 Estimation (Estimators of the standard deviation)

Exercise 1

1. Choose a value ofσ. ForN = 104,n= 100, drawN samples of sizenwith the normal distribution N(0, σ2).

2. For each of theN samples, 2 estimators ofσare considered: the values returned bysd, the square root of the empirical variance.

3. Draw the 2 boxplots. Which of the two estimators is a better estimator ofσ?

2 Confidence interval of an expectation

Exercise 2

In this exercise, we assume that X is a Gaussian sample, with known variance and unknown expec- tation.

1. Simulate a Gaussian sample X of lengthn = 50 with expectation µ= 1 and standard deviation σ = 1. Compute its mean ¯x. Compute the confidence interval ofµ at the level 0.95%, assuming the variance to be known.

2. Write a function confint.mean which takes the sample X, the known standard deviationσ and the confidence level, and returns the two bounds of the confidence interval.

(2)

confint.mean<-function(X,sigma,conf.level){

n<-length(X)

alpha<-1-conf.level xbar<-mean(X)

lowerb<-xbar-sigma/sqrt(n)*qnorm(1-alpha/2) upperb<-xbar+sigma/sqrt(n)*qnorm(1-alpha/2) return(c(lowerb, upperb))

}

Test it with the previous sampleX and confidence levels equal to 0.90%, 0.95%, 0.99%. Comment.

3. A confidence interval does not always include the true value. Simulate 100 samples of size n= 50 with expectation µ = 1 and standard deviation σ = 1 and assign it to X100. Compute the 100 confidence intervals at level 0.95% using theconfint.meanfunction. Plot the confidence intervals with the true values. Comment.

CI100<-apply(X100,1,confint.mean, sigma, 0.95) #100 confidence intervals matplot(CI100, rbind(1:100, 1:100), type=’l’, lty=1, ylab="") #plot of the C.I abline(v=mu) #true value

4. Simulate a sample X with N(0,1), of length n= 1000. For i= 1, . . . , n, compute the confidence intervals at levels 0.95 for the mean of the sample. sigma<-1

Xbar <- cumsum(X)/(1:n) # empirical means qalpha <- qnorm(1-alpha/2) # quantile

lowerb<-Xbar-qalpha*sigma/sqrt(1:n) # lower bounds upperb<-Xbar+qalpha*sigma/sqrt(1:n) # upper bounds

Represents as red dots the successive means, as blue dots the bounds of the CI’s at 0.95. Comment.

Exercise 3

In this exercise, we assume that X is a Gaussian sample, with unknown variance and unknown expectation.

1. Write a functionconfint.mean.Uwhich takes the sampleX and the confidence level, and returns the two bounds of the confidence interval. Test it with a sampleX and confidence levels equal to 0.90%, 0.95%, 0.99%. Comment.

2. The spreadsheether.txtcontains health data from 80 patients. Using theconfint.mean.Ufunc- tion, compute confidence intervals at level 0.95 for the mean of the following samples of heightof:

all patients, girls, boys, treated patients, untreated patients.

3. Compare the result with thet.test function of R.

t.test(H)

t.test(H)$conf.int

4. Give a 95% confidence interval for the variance, and for the standard deviation.

2

(3)

3 Confidence interval of a probability

Exercise 4

1. Simulate X in a binomial distribution with parameters n = 100 and p = 0.5. Estimate the probability p. Compute the 95% confidence interval ofp.

2. Repeat with n= 1000. Comment.

Exercise 5

In order to study the influence of X-rays on the spermatogenesis of Bombyx mori, males have been exposed to radiation on the second day and on the fourth day of the larval stage. These males have been mated with non exposed females, and the number of fertile eggs laid by the females have been counted:

out of a total of 5646 eggs laid, 4998 were fertile. In a control group of non exposed males and females, 5834 fertile eggs out of 6221 were obtained.

1. Find a 95% confidence interval for the proportion of fertile eggs after radiation exposure of males.

2. Find a 95% confidence interval for the proportion of fertile eggs of non exposed couples.

3. What do you think of the influence of radiation exposure on fertility?

3

Références

Documents relatifs

In terms of states and decisions, it means: when we want to explore a new decision from state s, we use information about all the decisions explored from this state s in the

2- Information on the use of teleconsultation as regards to digital technology features was collected and concerned the main benefits identified including four dummy

•  Atteinte rénale +/- •  Atteinte cardiaque ++ •  Canal carpien ++. Pronostic : décès après 10 ans

Abstract: In this short note, we show how to use concentration inequal- ities in order to build exact confidence intervals for the Hurst parameter associated with a

An analytical expression for the relative variance (or variability) of the electric power measured on a reference antenna has been derived by using a modal expansion of the

This confidence strategy is clearly opposed to the credibility strategy developed in central banks and the academic milieu after 1980, but also inflation targeting (cf. infra)

FUSION/SUBSCRIPTION ARCHITECTURE In this section we describe the architecture to allows the user - or a consumer - to dynamically request information from fusion process

Euclidean Delaunay Triangulations #include &lt;CGAL/Exact_predicates_inexact_constructions_kernel.h&gt; #include &lt;CGAL/Delaunay_triangulation_3.h&gt;