Question

Use the programming language R to code the following project.. * Make sure you turn in...

Use the programming language R to code the following project..

* Make sure you turn in your code and answers from each question. (not the raw data).
1. Generate 1000 random samples of size 40 from the normal distribution with mean µ = 3 and
standard deviation σ = 2. Compute 95% the confidence interval of 1000 samples and find the rate
of confidence interval contains the true mean. What did you learn from this simulation study?
2. For each of the distributions below, generate a random sample of size 100 and then plot the normal
probability plot (based on manual algorithm instead of built in function) of each data and discuss.
(a) t-distribution (df=1)
(b) t-distribution (df=10)
(c) t-distribution (df=100)
(d) standard normal distribution
3. Conduct the exercise 7.33 by R. Also, when you verify the normality assumption in part (b) of 7.33,

Homework Answers

Answer #1

1) The R code generte 1000 random samples of size from the normal distribution with mean µ = 3 and
standard deviation σ = 2 is given below. The 95% confidence interval is found as

, where is sample mean and is sample standard deviation.

set.seed(1234)
N <- 1000
n <- 40
mu <- 3
sigma <- 2
p <- 0
for (i in 1:N)
{
X <- rnorm(n,mean =mu, sd =sigma)
X_bar <- mean(X)
X_sd <- sd(X)
if (X_bar - 1.96*X_sd/sqrt(n)< mu & mu < X_bar + 1.96*X_sd/sqrt(n))
{
p <- p+1/N
}
}
p

The output is:

> p
[1] 0.94

We see that the rate of confidence interval contains the true mean is 94% which ios close to theoretical 95%.

We are required to solve only one question. Please post the remaining questions as another post.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Using R programming language, complete the following. 1. Generate the bivariate normal sample of size 100...
Using R programming language, complete the following. 1. Generate the bivariate normal sample of size 100 with parameters a. marginal mean of X equal to 1, b. marginal mean of Y equal to 2, c. marginal variance of X equal to 3, d. marginal variance of Y equal to 4, e. correlation between X and Y equal to -1/2. You can use the function mvrnorm(), first installing its package by the code if (! require ("MASS")) install.packages("MASS"); library ("MASS") 2....
The following question can be answered in R code (using R-Studio or a program of your...
The following question can be answered in R code (using R-Studio or a program of your choice). Load the “star” data from the “faraway” package, and model “temp” using “light”. One may also suspect that the residuals (use all the data) follow a t distribution instead of normal. Using the same logic that we produced the QQ plot for comparing to the normal distribution, produce a QQ plot for comparing to a t distribution. You need to decide the degrees...
R Programming: a.Choose 10 random values of X having the Normal(4, 1) distribution. Use t.test to...
R Programming: a.Choose 10 random values of X having the Normal(4, 1) distribution. Use t.test to compute the 95% confidence interval for the mean. Is 4 in your confidence interval? b.Replicate the experiment in part a 10,000 times and compute the percentage of times the population mean 4 was included in the confidence interval. c.Repeat part b, except sample your 10 values when X has the Exponential(1/4) distribution. What is the mean of X? What percentage of times did the...
R Code Directions: All work has to be your own, you may not work in groups....
R Code Directions: All work has to be your own, you may not work in groups. Show all work. Submit your solutions in a pdf document on Moodle. Include your R code (which must be commented and properly indented) in the pdf file. Name this pdf file ‘your last name’-HW5.pdf. Also submit one text file with your R code, which must be commented and properly indented. You may only use ‘runif’ to generate random numbers; other random number generating functions...
Use R to code a function to generate a random sample of size n from the...
Use R to code a function to generate a random sample of size n from the Beta(a, b) distribution by the acceptance-rejection method. (1) Generate a random sample of size 3000 from the Beta(4,3) distribution. (2) Graph the histogram of the sample with the theoretical Beta(4,3) density superimposed. Answer the above questions by showing the R codes and results.
Please provide the code in the language R. (请提供语言R的代码) Suppose the incubation period, T , of...
Please provide the code in the language R. (请提供语言R的代码) Suppose the incubation period, T , of a certain disease can be modeled by an exponential distribution with a mean of 4.5 days 1. Run a simulation to estimate the probability that, among 100 people who have contracted the disease, 80 or more people will develop symptoms within 5 days. 2. Suppose the number of new cases contracting the disease today follows a Poisson distribution with a mean of 100 people....
This problem is to be done in R. Maria claims that she has drawn a random...
This problem is to be done in R. Maria claims that she has drawn a random sample of size 30 from an Exp(10) distribution (λ = 10, rate = 0.1). The mean of her sample is 12. (a) What is the expected value of a sample mean? (b) Run a simulation by drawing 1000 random samples, each of size 30, from an Exp(10) distribution, and compute the means for each sample. What proportion of the sample means are ≥ 12?...
R Code Directions: All work has to be your own, you may not work in groups....
R Code Directions: All work has to be your own, you may not work in groups. Show all work. Submit your solutions in a pdf document on Moodle. Include your R code (which must be commented and properly indented) in the pdf file. Name this pdf file ‘your last name’-HW5.pdf. Also submit one text file with your R code, which must be commented and properly indented. You may only use ‘runif’ to generate random numbers; other random number generating functions...
r code Load the “star” data from the “faraway” package, and model “temp” using “light”. library(faraway)...
r code Load the “star” data from the “faraway” package, and model “temp” using “light”. library(faraway) data(star) fit = lm(temp ~ light, data = star) One may also suspect that the residuals (use all the data) follow a t distribution instead of normal. Using the same logic that we produced the QQ plot for comparing to the normal distribution, produce a QQ plot for comparing to a t distribution. You need to decide the degrees of freedom yourself (consider df...
Use either R or Excel for the following. Provide the formulas or code that you are...
Use either R or Excel for the following. Provide the formulas or code that you are using. Let x1 be a random variable that is N(100, 225). Let x2 be a random variable that is U(50,150) and let x3 be a random variable that is U(500,1500). Set Y = (X1)(X2)/ (X3) a) Use R to create 500 random numbers of each type (X1, X2, X3 and Y). b) Estimate P(0.1 < Y < 0.25) c) Estimate E(Y) and the Standard...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT