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
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...
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....
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...
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....
Write an R code that does the following: (a) Generate n samples x from a random...
Write an R code that does the following: (a) Generate n samples x from a random variable X that has a uniform density on [0,3]. Now generate samples of Y using the equation: y = α/(x + β). For starters, set α = 1, β = 1 The R code: x=runif(n=1000, min = 0, max = 3) x y=1/x+1 y Please answer the following: b) Use plot(x,y) to check if you got the right curve. c) How does the correlation...
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...
PLEASE USE R CODE!! Continue to generate standard normal random variables until you have generated n...
PLEASE USE R CODE!! Continue to generate standard normal random variables until you have generated n of them, where n≥100 is such that S/sqrt(n) <0.1, where S is the sample standard deviation of the n data value. (a)How many normals do you think will be generated? (b)What is the sample mean of all the normals generated? (c)What is the sample variance?