9 9th Tutorial
Exercise 9.1 All the 80 farms in a population are stratified by farm size. The expenditure on the insecticides used during the last year by each farmer is presented in the dataset
urlfile<- "https://raw.githubusercontent.com/F3bdulmajeed/STAT_331/main/farmdata.csv"
Farms<-read.csv(urlfile)
- Compute the overall population mean \(\bar{Y}\) and the population mean square \(S^2\).
- Verify that population mean equal the weighted average of the means of the strata.
- Determine the number of units to be selected from each stratum with proportional allocation, equal allocation, and Nyman allocation of a sample of size \(n=24\).
- Determine the variance of the sample mean for stratified sampling with proportional allocation, equal allocation, and Nyman allocation of a sample of size \(n=24\). Assume that the sampling is WOR.
- Compare the relative precision of stratified sample mean \(\bar{Y}_{str}\) based on each of the above mentioned allocations, with respect to the simple random sample mean \(\bar{Y}_{srs}\)
- Select a stratified sample of \(24\) farmers by using Proportional allocation.(use R program)
## stratum
## 1 2 3
## 20 36 24
## compute population size, mean for each stratum 1,2 and 3.
#sample size, mean and var for strata 1
Y1<-Y[Farm == 1]
N1=length(Y1)
Y1_bar=mean(Y1)
V1=var(Y1)
#sample size, mean and var for strata 2
Y2<-Y[stratum==2]
N2=length(Y2)
Y2_bar=mean(Y2)
V2=var(Y2)
#sample size, mean and var for strata 3
Y3<-Y[stratum==3]
N3=length(Y3)
Y3_bar=mean(Y3)
V3=var(Y3)
N=N1+N2+N3 #Population size
V1; V2 ; V3
## [1] 169.5158
## [1] 70.56111
## [1] 61.44928
## [1] 43.7875
#b.verify that population mean equal the weighted average of the means of the strata
Wh=c(N1/N,N2/N,N3/N)
mean_str=Wh[1]*Y1_bar+Wh[2]*Y2_bar+Wh[3]*Y3_bar
mean_str
## [1] 43.7875
## [1] 268.6758
# c. determine the variance of the sample mean for SRS with the same size 24
n=24
Var_srs=((N-n)/(N*n))*pop_v
Var_srs
## [1] 7.836377
## [1] 8
n1=n2=n3=nh
#d. variance
Var_str.E=((Wh[1])^2)*((N1-n1)/N1)*(V1/n1)+((Wh[2])^2)*((N2-n2)/N2)*(V2/n2)+((Wh[3])^2)*((N3-n3)/N3)*(V3/n3)
Var_str.E
## [1] 2.644647
# e.Relative efficiency
RE= Var_srs/ Var_str.E*100
## c. determine the variance of the sample mean for stratified sampling
#with proportional allocation
n1_p=round(Wh[1]*n, digits = 0) #Rounds a value to the nearest integer.
n2_p=round(Wh[2]*n, digits = 0)
n3_p=round(Wh[3]*n, digits = 0)
n1_p; n2_p;n3_p;
## [1] 6
## [1] 11
## [1] 7
np=c(n1_p,n2_p,n3_p)
## d. determine the variance of the sample mean for stratified sampling
#with proportional allocation of a sample of size n=12
#variance
Var_str.p=((Wh[1])^2)*((N1-n1_p)/N1)*(V1/n1_p)+((Wh[2])^2)*((N2-n2_p)/N2)*(V2/n2_p)+((Wh[3])^2)*((N3-n3_p)/N3)*(V3/n3_p)
Var_str.p
## [1] 2.69774
## [1] 290.4794
## c. determine the variance of the sample mean for stratified sampling
#with Neyman allocation
Nh=c(N1,N2,N3)
Vh=sqrt(c(V1,V2,V3))
Nunv=sum(Nh[1]*Vh[1]+Nh[2]*Vh[2]+Nh[3]*Vh[3])
Nunv
## [1] 750.9339
## [1] 8
## [1] 10
## [1] 6
#d.variance
Var_str.o=((Wh[1])^2)*((N1-n1_o)/N1)*(V1/n1_o)+((Wh[2])^2)*((N2-n2_o)/N2)*(V2/n2_o)+((Wh[3])^2)*((N3-n3_o)/N3)*(V3/n3_o)
Var_str.o
## [1] 2.517866
#e.Relative efficiency
RE= Var_srs/ Var_str.o*100
#f) Select a stratified sample of 24 farmers by using Proportional allocation.
RNGkind(sample.kind = "Rejection")
set.seed(200)
sample1=sample(Y1,6)
sample1
## [1] 69 60 50 60 48 79
## [1] 36 39 44 35 38 48 39 42 55 61 36
## [1] 40 18 42 18 26 36 31
## [1] 43.64286
svar_str.p=((Wh[1])^2)*((N1-n1_p)/N1)*(s1/n1_p)+((Wh[2])^2)*((N2-n2_p)/N2)*(s2/n2_p)+((Wh[3])^2)*((N3-n3_p)/N3)*(s3/n3_p)
svar_str.p
## [1] 2.79218
Exercise 9.2 The list of all the \(50,000\) adults in a town was available. In order to estimate proportion of literate adults (educated up to at least 8\(^{th}\) grade), the population was stratified into 3 strata with respect to age. A WOR random sample of size 500 persons was drawn using proportional allocation. The sample size allocation to each stratum and the number of literate persons recorded in sample of size \(n_h, h = 1, 2, 3\) are given below:
Compute the estimate of proportion of literate persons in the town, and construct confidence interval for it.
\(N=N_1+N_2+N_3=50000\) The estimate of the required overall population proportion is \[p_{str}=\sum_{h=1}^{L}w_h p_h =w_1 p_1+w_2 p_2+w_3 p_3\]
\[=(0.512)(0.9492)+(0.362)(0.7956)+(0.126)(0.4921)= 0.8360\] The estimate of variance is \[v(p_{str})=\sum_{h=1}^{L}w_{h}^{2} \frac{p_h q_h}{n_h-1} \frac{N_h-n_h}{N_h} =4.0414\] The confidence interval for population proportion is
\[p_{str} \pm Z_{1-∝/2} \times se(p_{str})\] \[ [0.8057 ,0.8663 ] \]
To summarize, the sample estimate of proportion indicates that about 83.6 percent is literate with CI between \([0.8057 ,0.8663 ]\)
## [1] 0.512
## [1] 0.9492188
## [1] 0.05078125
## [1] 0.362
## [1] 0.7955801
## [1] 0.2044199
## [1] 0.126
## [1] 0.4920635
## [1] 0.5079365
## [1] 0.836
Var_str_prop=((W1^2)*(N1-n1)*p1*q1/(N1*(n1-1))+((W2^2)*((N2-n2)*p2*q2/N2*(n2-1)))
+ +((W3^2)*((N3-n3)*p3*q3/N3*(n3-1))))
Var_str_prop
## [1] 4.041403