Suppose that one-way ANOVA Iis used to compare r means. For each i, i = 1, 2, ..
ID: 3171288 • Letter: S
Question
Suppose that one-way ANOVA Iis used to compare r means. For each i, i = 1, 2, ..., r, we draw n_i independent data X_ij. Assume that X_ij are independent, and follow a standard exponential distribution X_ij ~ Exp(1), j = 1, ..., n_i, I = 1, ..., r F_exp-statistic is defined as F_exp = SST/(r - 1)/SSE/(n - r) where n = sigma_i = 1^r n_i. Let r = 4 and n_i = 3. Use random number generator to generate 10^5 sets of data, and get the emperical distribution of F_exp. Compare the empirical distribution of F_exp with the distribution of F(r - 1, n - r). You may compare the means, the medians, and the 95th percentiles. Let r = 4 and n_i = 30. Repeat the simulation in (a) and compare the empirical distribution and the F-distribution. Change the distribution. Suppose that X_ij follows a Beta distribution with parameter alpha = 5, beta = 2 X_U ~ Beta (5, 2) Repeat the simulation and comparisons, with (1) r = 4 and n_i = 3 and (2) r = 4 and n_i = 30.Explanation / Answer
The r code is given below please compile it to get the idea :
1.1
x=array(dim=c(4,3))
for(k in 1:10000)
{
for(i in 1:4)
x[i,]=rexp(3)
c=apply(x,2,mean);c
d=apply(x,1,mean);d
t=var(as.vector(x))*11
f[k]=var(d)/(t-var(d)*3)*8;f
}
f1=rf(10000,3,8)
qqplot(f,f1)
#emperical
mean(f)
median(f)
quantile(f,0.95)
#thoretical
mean=8/(8-2);mean #as the mean comes out to be n/(n-2) for a f(m,n) distn.
median=8/3*((9-2)/(24-2));median # as the median comes out to be n/m*(3*m-2)/(3*n-2) (apx.) for a f(m,n) distn.)
qf(0.95,3,8)
s=cbind(emperical=f,theoritical=f1);s # comparison between the two distributions
1.2
x=array(dim=c(4,30))
for(k in 1:10000)
{
for(i in 1:4)
x[i,]=rexp(30)
c=apply(x,2,mean);c
d=apply(x,1,mean);d
t=var(as.vector(x))*119
f[k]=var(d)/(t-var(d)*30)*116;f
}
f1=rf(10000,3,116)
qqplot(f,f1)
#emperical
mean(f)
median(f)
qf(0.95,3,116)
#thoretical
mean=116/(116-2);mean #as the mean comes out to be n/(n-2) for a f(m,n) distn.
quantile(f,0.95)
median=116/3*((9-2)/(348-2));median # as the median comes out to be n/m*(3*m-2)/(3*n-2) (apx.) for a f(m,n) distn.)
s=cbind(emperical=f,theoritical=f1);s # comparison between the two distributions
---------
2.1
x=array(dim=c(4,3))
for(k in 1:10000)
{
for(i in 1:4)
x[i,]=rbeta(3,5,2)
c=apply(x,2,mean);c
d=apply(x,1,mean);d
t=var(as.vector(x))*11
f[k]=var(d)/(t-var(d)*3)*8;f
}
f1=rf(10000,3,8)
qqplot(f,f1)
#emperical
mean(f)
median(f)
quantile(f,0.95)
#thoretical
mean=8/(8-2);mean #as the mean comes out to be n/(n-2) for a f(m,n) distn.
median=8/3*((9-2)/(24-2));median # as the median comes out to be n/m*(3*m-2)/(3*n-2) (apx.) for a f(m,n) distn.)
qf(0.95,3,8)
s=cbind(emperical=f,theoritical=f1);s # comparison between the two distributions
2.2
x=array(dim=c(4,30))
for(k in 1:10000)
{
for(i in 1:4)
x[i,]=rbeta(30,5,2)
c=apply(x,2,mean);c
d=apply(x,1,mean);d
t=var(as.vector(x))*119
f[k]=var(d)/(t-var(d)*30)*116;f
}
f1=rf(10000,3,116)
qqplot(f,f1)
#emperical
mean(f)
median(f)
qf(0.95,3,116)
#thoretical
mean=116/(116-2);mean #as the mean comes out to be n/(n-2) for a f(m,n) distn.
quantile(f,0.95)
median=116/3*((9-2)/(348-2));median # as the median comes out to be n/m*(3*m-2)/(3*n-2) (apx.) for a f(m,n) distn.)
s=cbind(emperical=f,theoritical=f1);s
# I did not use 'function' ,as it slows down the compiler, resulting in a tedious algo. I hope this code will satisfy your need. hint: observe the qqplots
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.