## Set A ## 1) Model Sampling from Cauchy and Laplace distribution > # a) > # X follows cauchy disribution with parameter theta=10 and lambda=1 > #using inverse Transformation CDF > n=11 #size of random sample to be drawn from Cauchy distribution > lambda=1 #Scale Parameter > theta=10 #Location parameter > # As we Know that evry distribution cdf follows standard uniform distribution > y=runif(n) # Generating random sample of size 11 from uniform distribution > x=lambda*tan(pi* (v-0.5))+theta;x > # b) Median of the cauchy sample obtain From obove > median(x) ## Cauchy= L/2*exp(-L|x-u|) ## 2) Log normal Cancer # (1/(x-a)sigrt2pi)exp(-1/2sigsq(logx-a - u)sq) > # Fiting log normal distribution > LL=seq(0,60,10);LL #lower Limit of given data > UL=seq(10,70,10);UL #upper limit of the given data > Freq=c(20,90,52,11,6,4,1);Freq > N=sum(Freq) > x=(UL+LL)/2; #mid point of the gien data > d=data.frame("lower limit"=LL, "Upper limit"=UL,"mid point"=x, "frequency"=Freq) > d > M12=sum(Freq*x/sum(Freq); M12 # Frist sample raw Movement used for estimating mean and Sigma > M13=sum(Freq*(x^2))/sum(Freq);M13 # Second sample raw moment used for estimating mean sigma > sigma_est=log(M13,base=exp(1))-(2*log(M12,base =exp (1))); sigma_est ##estimating sigma for calculating Probabilities > mu_est=(2*log(M12,base=exp(1)))-(log(M13,base=exp(1))/2); mu_est ##estimating mean for calculating probabilities > a=plnorm(UL,mu_est,sqrt(sigma_est));a #calculating cumulative Probabilities > px=с() > px[1]=a[1] > for (i in 1: (length(a)-1)){ + px[i+1]=ali+1]-a[i] +} > ExFreq=round(N*px,2);ExFreq > sum(ExFreq) > D1= data.frame(d, "expected"= Exfreq) # 3) literates 2 year Ratio and Regression mthd › #Ratio and regression method of estimation Comparsion with SRSWOR > x=с(109,101,125,254,559,359,427,481);X > y=c(99,112,111,278,634,355,399,489); Y > N=170 #No observation of given data X. > n=length(y) > Xt=21288000 #population total of given data X > Х_bar_N=xt/N;X_bar_N #Population Mean of given data of X > y_bar_n=mean(y) > x_bar_n=mean(x) > #Ratio method. > Rn=y_bar_n/x_bar_n;Rn #ratio of sample mean of y and x > Y_bar_N=Rn*X_bar_N;Y_bar_N #Estimate of Population mean of Y > sy_sq=var(y);sy_sq #sample mean square of y > sx_sq=var(x);sx_sq #sample mean square of x > sxy_sq=var(x,y);sxy_sq #sample mean square of xy > SE_Y_totalhat=N*sqrt(((1/n)-(1/N))*(sy_sq+Rn^2*sx_sq-(2*Rn*sxy_sq)));SE_Y_totalhat #Estimate of SE of population total of Y > #Regression method: > byx=sxy_sq/sx_sq;byx #regression coefficient of Y on X > Y_hat=y_bar_n+(byx*(X_bar_N-x_bar_n));Y_hat #Estimate of Population mean of Y > Y_hat_total=N*Y_hat;Y_hat_total #Estimate of Population total of Y > SE_Y_total1=N*sqrt((N-n)/(N*n))*(sy_sq+(byx^2*sx_sq)-(2*byx*sxy_sq)));SE_Y_total1 #Estimate of SE of population total of Y > #comparison between SRSwor > var_y_bar=((1/n)-(1/N))*sy_sq;var_y_bar #variance of sample mean under SRSWOR › SE_Y_hat=N*sqrt(var_y_bar);SE_Y_hat #S.E of sample mean under SRSWOR > #conclusion- SE(Y_hat)SRSWOR>SE(Y_hat)RATIO>SE(Y_hat)REGRESSION ># This implies that variation of regression estimator is minimum and use supplementary information increases the precision. ## SET B ## 1. B > #que no 4 > mu=5 > sigma=sqrt(4) > set.seed (8) > u=runif(8,0,1) #where u and v follows U(0,1) > U > v=runif (8,0,1) > V > z=sqrt(-2*log(x=u)) *cos(2*pi*v) #random sample from N (0,1) > Z 1>x=mu+(2* sigma) #random sample from N(5,4) > X > mean (X) > #conclusion-Hence our sample mean is close to population mean but sample variance shows some deviation but as the sample size tends to infinity it will close to population variance #1.C > #Weibull distribution with alpha=15 and beta=10 > alpha3=3 #parameter values of weibull distribution > beta3=1 > x=seq (-0.01,15,0.1);x > px4=dweibull(x,shape=beta3,scale=alpha3);px > plot(x,px4,col="pink",xlab="variable", ylab="probability", lwd=4,type="1", ylim=c(0,0.92)) > #а) > alpha=1 > beta=2 #parameter values of weibull distribution > x=seq(-0.01,15,0.1);x > px=dweibull(x,shape=beta,scale=alpha);px > lines(x=x,y=px,lty=3,col="yellow", lwd=3) >#D) > alpha1=5 #parameter values of weibull distribution > beta1=1 > px1=dweibull(x,shape=beta1,scale=alpha1);px > lines(x=x,Y=px1,col="blue", lwd=4,Ity=2) > #C) > alpha1=1 #parameter values of weibull distribution > beta1=1 > px2=dweibull(x,shape=beta1,scale=alphal);px > lines(x=x,y=px2,col="green", lwd=3,Ity=2) > >#d) > alpha2=10 #parameter values of weibull distribution > beta2=5 > px3=dweibull(x,shape=beta2,scale=alpha2); px > lines(x=x,y=px3,col="violet", wd=4,Ity=2) legend (locator(1), legend=c("W(alpha=3,beta=1)", "W(alpha=1,beta=2)", "W(alpha=5,beta=1)", "W(alpha=1,beta=1)", "W(alpha=10, beta=5)") fill=c("pink", "yellow","blue", "green", "violet")) > #conclusion-As we we increase the values of both the shape parameter it slowly becomes symmetric from strong negatively skewed. ###proportional and neyman allocation > N1=80 #population > N2=60 > N3=40 > N4=100 > N5=100 > Ni=c(80,60,40,100,120); Ni #population of each strata > N=sum(N1,N2,N3, N4, N5);N > y_bar_i=c(82.3,161.5,139.2,239.1,200);Y_bar_i #Popn mean of each strata > Si=c(21.3,17.7,14.7,15.3,18.9);Si > n=40 > # Obtain the size of the sub sample from each stratum > # for population allocation > ni=(n/N)*Ni;ni > n1=ni[1];n1 > n2=ni|2];n2 > n3=ni[3];n3 > n4=ni[4];n4 > n5=ni[5];n5 ># for Nayman's allocation > ni=(n*Ni*Si)/sum(Ni*Si) > n1=round(ni(1],0);n1 > n2=round(ni[2],0);n2 > n3=round(ni[3],0);n3 > n4=round(ni[4],0);n4 > n5=round (ni[5],0);n5 > # To obtain S.E of the estimate of population mean and population total > # under population allocation > pi=c(N1/N,N2/N,N3/N, N4/N,N5/N);pi > S_E_est_ Ybar1=sqrt(((1/n)-(1/N))*sum(pi*Si^2));S_E_est_Ybar1 > S.E_est_Yt1=sqrt(N*S_E_est_Ybar1);S.E_est_Yt1 › # Under Nayman's allocation > S.E_est_ Ybar2=sqrt((1/n)*(sum(pi*Si))*2)-((1/N)*sum(pi*Si^2)));S.E_est_Ybar2 > S.E_est_Vt2=sqrt(N*S.E_est_Ybar2);S.E_est_Yt2 > #UNDER SRSWOR > Y_bar_N=sum(Y_bar_i*Ni)/N;Y_bar_N > S.E_est_Ybar3=sart((N-n)/(N*n))*(1/(N-1)) *(Isum(Ni-1) *Si^2)+(sum((Y_bar_i-Y_bar _N)*2*Ni));S.E_est_Ybar3 > S.E_est_Yt3=sqrt(N*S.E_est_Ybar3);S.E_est_Yt3 › # conclusion:since varience of ybarst of population mean under SRSWOR is more than the varience under population allocation and Neyman's allocation SET C Q1. A(i) > x=sort(c(24,38,61,22,16,57,31,29,35));x > length(x) > LL=seq(1,9,1);LL > UL=sort(seq(1,9,1), decreasing = TRUE); UL > d=data.frame(LL,UL);a > d1=subset(d,LL