Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JUST PARTS C, D, and E Function (part B) is: reject.prob=function(n,mean0,theta,mu1,sigma1,mu2,sigma2,alpha,reps) { tstat=numeric(reps) s1=0 for(j in 1:reps) { w=numeric(n) for(i in 1:n) { u=rbinom(1,1,theta) if(u==1)
JUST PARTS C, D, and E
Function (part B) is:
reject.prob=function(n,mean0,theta,mu1,sigma1,mu2,sigma2,alpha,reps) { tstat=numeric(reps) s1=0 for(j in 1:reps) { w=numeric(n) for(i in 1:n) { u=rbinom(1,1,theta) if(u==1) w[i]=rnorm(1,mu1,sigma1) else w[i]=rnorm(1,mu2,sigma2) } tstat[j]=sqrt(n)*(mean(w))/sd(w) if(abs(tstat[j])>qt(1-alpha/2,n-1)) s1=s1+1 } rej_prob=s1/reps return(rej_prob) }
Question 2 (20 points) Let W = YU + (1 - Y)V, where Y ~ Bern(0),U ~ N(41,6),V~ N(H2, o) and Y, U, V are independent, i.e., W is a mixture of normal distributions and we know E(W) = 0u1 + (1 - 0)u2. Suppose we have W1,W2,...,W, being independent copies of W. We are interested in testing the hypotheses Ho: 041 +(1 u2 = 0 and He: Oui + (1 - 0)u2 + 0 using a two-sided t-test. (b) (4 points) Create a function named reject.prob to estimate the probability that the null hypothesis will be rejected under different data generating distributions. Your function should have the following parameters: . n: sample size in each realization of the data meano: hypothesized mean of the distribution theta: weight of the first component of the distribution mul: mean of the first normal component sigmal: standard deviation of the first normal component mu2: mean of the second normal component sigma2: standard deviation of the second normal component alpha: significance level of the test reps: number of replications of Monte Carlo simulation. And it should return a estimated rejection probability. (c) (4 points) Let a =0.05. Calculate the number of replications needed to estimate Type I error probability of the test with a margin of error of at most 0.01 at the conservative approximate 99% confidence level. (d) (4 points) Test your function by estimating the type I error probability of the test Ho : 0u1 + (1 - 0)H2 = 0 and Hq : Oui + (1 - 0)u2 #0 when n=200,0 =0.5,4 =-1, 42 = 1,0 =0.52, =1, a=0.05 using reps calculated above. Create a 99% Wald CI for the Type I error probability. (e) (4 points) Test your function by producing a plot of a simulated estimate of the power curve of the test H: 0u1 + (1 - 0)H2 = 0 and Hq : Oui + (1 - 0)u2 #0 by using n= 200, 0 = 0.5,4 =-1,,g} = 0.52,63 = 1, H2 {1,1.05.1.1,..., 2} using reps calculated above. Note that at H2 = 1, Ho is correct, so plot the simulated estimate of type I error in that case. Question 2 (20 points) Let W = YU + (1 - Y)V, where Y ~ Bern(0),U ~ N(41,6),V~ N(H2, o) and Y, U, V are independent, i.e., W is a mixture of normal distributions and we know E(W) = 0u1 + (1 - 0)u2. Suppose we have W1,W2,...,W, being independent copies of W. We are interested in testing the hypotheses Ho: 041 +(1 u2 = 0 and He: Oui + (1 - 0)u2 + 0 using a two-sided t-test. (b) (4 points) Create a function named reject.prob to estimate the probability that the null hypothesis will be rejected under different data generating distributions. Your function should have the following parameters: . n: sample size in each realization of the data meano: hypothesized mean of the distribution theta: weight of the first component of the distribution mul: mean of the first normal component sigmal: standard deviation of the first normal component mu2: mean of the second normal component sigma2: standard deviation of the second normal component alpha: significance level of the test reps: number of replications of Monte Carlo simulation. And it should return a estimated rejection probability. (c) (4 points) Let a =0.05. Calculate the number of replications needed to estimate Type I error probability of the test with a margin of error of at most 0.01 at the conservative approximate 99% confidence level. (d) (4 points) Test your function by estimating the type I error probability of the test Ho : 0u1 + (1 - 0)H2 = 0 and Hq : Oui + (1 - 0)u2 #0 when n=200,0 =0.5,4 =-1, 42 = 1,0 =0.52, =1, a=0.05 using reps calculated above. Create a 99% Wald CI for the Type I error probability. (e) (4 points) Test your function by producing a plot of a simulated estimate of the power curve of the test H: 0u1 + (1 - 0)H2 = 0 and Hq : Oui + (1 - 0)u2 #0 by using n= 200, 0 = 0.5,4 =-1,,g} = 0.52,63 = 1, H2 {1,1.05.1.1,..., 2} using reps calculated above. Note that at H2 = 1, Ho is correct, so plot the simulated estimate of type I error in that case
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started