In: Statistics and Probability
Please use R software to do the following study.:
Conduct a short study on the performance of the 1 sample t-test under the following settings
Setting 1:
Ho: mu=20 Ha: mu<>20
n=30
True distribution is normal with mean=20, sd=3
Setting 2:
Ho: mu=20 Ha: mu<>20
n=10
True distribution is normal with mean=20, sd=3
Setting 3:
Ho: mu=20 Ha: mu<>20
n=30
True distribution is exponential with parameter lamda=1/20 (mean=20)
Setting 4:
Ho: mu=30 Ha: mu<>20
n=10
True distribution is exponential with parameter lamda=1/20 (mean=20)
The report should answer the following question:
In which settings is the one-sample t-test able to retain control over type 1 error?
The report should contain:
Introduction
Methodology
Results
Conclusion
Introduction: The one-sample t-test is used to determine whether a sample comes from a population with a specific mean. This population mean is not always known, but is sometimes hypothesized. As a parametric procedure. one sample t-test has some basic assumptions such as observations are independent and continuous, observation come from population parent is normal etc. Here, we test if the statistic from the observed data is consistent with the statistics calculated from data generated under the null hypothesis.
Methodology:
Under certain null hypothesis for a particular model
1 Generate random sample X1 ,
X2, . . . , Xn from the null
distribution or model
2 Compute the test statistic.
3 Repeat S times: T (1 ),
T(2), . . . , T(S)
4 check rejection criterion at significance level
α.
5 Draw conclusion with varying sample size.
Results
Setting 1.
n=30
# sample size
mu=20
# true value of a parameter
sig=3
# true value of a parameter
y=rnorm(n, mu,
sig) #
generate normal random number
sig_y=sqrt(var(y)/n) #
compute standard error
mu_y=sum(y)/n
# compute estimator
tobs=(mu_y-mu)/sig_y
# compute test statistic
tobs
ifelse(abs(tobs)>qnorm(0.95),"Reject", "Accept" )
Accept
Setting 2.
n=10
# sample size
mu=20
# true value of a parameter
sig=3
# true value of a parameter
y=rnorm(n, mu,
sig) #
generate normal random number
sig_y=sqrt(var(y)/n) #
compute standard error
mu_y=sum(y)/n
# compute estimator
tobs=(mu_y-mu)/sig_y
# compute test statistic
tobs
ifelse(abs(tobs)>qt(0.05,n-1),"Reject", "Accept" )
Reject
Setting 3.
n=30
# sample size
ld=1/20
# true value of a parameter
y=rexp(n, ld) #
generate normal random number
sig_y=sqrt(var(y)/n) #
compute standard error
mu_y=sum(y)/n
# compute estimator
tobs=(mu_y-20)/sig_y
# compute test statistic
tobs
ifelse(abs(tobs)>qnorm(0.95),"Reject", "Accept" )
Accept
Setting 4
n=10
# sample size
ld=1/20
# true value of a parameter
y=rexp(n, ld) #
generate normal random number
sig_y=sqrt(var(y)/n) #
compute standard error
mu_y=sum(y)/n
# compute estimator
tobs=(mu_y-20)/sig_y
# compute test statistic
tobs
ifelse(abs(tobs)>qt(0.95,n-1),"Reject", "Accept" )
Accept
Settings 2 is the one-sample t-test able to retain control over type 1 error.