Question

In: Statistics and Probability

Coding Language: R Generate 100 observations from the normal distribution with mean 3 and variance 1....

Coding Language: R

Generate 100 observations from the normal distribution with mean 3 and variance 1.

Compute the sample average, the standard error for the sample average, and the 95% confidence interval.

Repeat the above two steps 1000 times. Report (a) the mean of the 1000 sample means, (b) the standard deviation of the 1000 sample means, (c) the mean of the 1000 standard errors, and (d) how many times (out of 1000) the 95% confidence intervals include the population mean.

Solutions

Expert Solution

approximately 950 time confidence interval will include population mean.

#Generating 100 observations from the N(mean=3,Var=1)


rand_n<-rnorm(100,mean=3,sd=1)
# sample average
sample_mean=mean(rand_n)
#standard error for mean
se <- sd(rand_n) / sqrt(length(rand_n))
#We can calculate a 95% confidence interval for a sample mean by adding and subtracting 1.96 standard errors to the point estimate (See Section 4.2.3 if you are unfamiliar with this formula).


lower <- sample_mean - 1.96 * se
upper <- sample_mean + 1.96 * se
c(lower, upper)
# to repeat the above steps
#we need to first create empty vectors where we can save the means and standard deviations that will be calculated from each sample.
samp_mean <- rep(NA, 1000)
samp_sd <- rep(NA, 1000)
n <- 1200
for(i in 1:1000){
samp <- rnorm(100,mean=3,sd=1) # obtain a sample of size 100 observations from the N(mean=3,Var=1)
samp_mean[i] <- mean(samp) # save sample mean in ith element of samp_mean
samp_sd[i] <- sd(samp) # save sample sd in ith element of samp_sd
samp_s[i] <- sd(samp) / sqrt(length(samp)) # save sample se in ith element of samp_s
}

lower_vector <- samp_mean - 1.96 * samp_sd / sqrt(n)
upper_vector <- samp_mean + 1.96 * samp_sd / sqrt(n)
c(lower_vector, upper_vector)


#


Related Solutions

Use R and perform following: Generate 1000 observations from an exponential distribution with mean 10. Generate...
Use R and perform following: Generate 1000 observations from an exponential distribution with mean 10. Generate 1000 observations from a central t-distribution with 8 degree of freedom. Make a qqplot of observations in problem 1 versus quantiles generated from a t-distribution with 8 degree of freedom. Can the t distribution be used to approximate data in part 1?Submit the plot. Repeat above part but submit a qqplot of the observations in 1 versus quantiles from an exponential with mean 1....
Generate 1000 random numbers from a normal distribution with mean 1 and variance 2 using Box‐Muller...
Generate 1000 random numbers from a normal distribution with mean 1 and variance 2 using Box‐Muller transformation in R.
Generate 100 samples of size n=8 from an exponential distribution with mean 3 . Each row...
Generate 100 samples of size n=8 from an exponential distribution with mean 3 . Each row of your data will denote an observed random sample of size 8, from an exponential distribution with mean 3. Obtain sample mean for each sample, store in another column and make a histogram for sample means. Repeat for n=100. Compare and interpret the histograms you obtained for n=8 and n=100. Submit the histograms along with your one small paragraph comparison. Can you solve it...
Solve using coding in R script: 1) Given a standard normal distribution, find the value of...
Solve using coding in R script: 1) Given a standard normal distribution, find the value of k such that P(Z < k) = 0.0197. 2) Given a normal distribution with mu = E(X) = 32 and sigma^2 = V(X) = 30, find the normal curve area to the left of x = 31. Report your code as well as your final answer (4 decimals). 3) A company pays its employees an average wage of $17.90 an hour with a standard...
How to use mean-variance analysis with a normal distribution?
How to use mean-variance analysis with a normal distribution?
Let ?1,?2, ?3, … , ?25, be a random sample from a normal distribution having variance...
Let ?1,?2, ?3, … , ?25, be a random sample from a normal distribution having variance 100. a. Find the rejection region for a test at level ? = .1 of ?0: ? = 0 ?1: ? = 1.5 b. What is the power of the test?
The following eight observations were drawn from a normal population whose variance is 100: 12 8...
The following eight observations were drawn from a normal population whose variance is 100: 12 8 22 15 30 6 29 58 Part A What is the standard error of the sample mean, based on the known population variance? Give your answer to two decimal places in the form x.xx Standard error: Part B Find the lower and upper limits of a 90% confidence interval for the population mean. Give your answer to two decimal places in the form xx.xx...
Write the R code First, generate 1000 observations from a binomial distribution with n=30 and p=0.2...
Write the R code First, generate 1000 observations from a binomial distribution with n=30 and p=0.2 Use the 1000 observations you generated: a) Generate poisson, binomial, negative binomial Diagnostic Distribution Plots using distplot. b) Generate a histogram and overlay a kernel estimator of the density (You can use: binom <- rbinom(n=1000,size=30, prob=0.2))
Mean and Variance of: continuous uniform distribution, normal distribution, normal approximation for binomial and Poisson distributions,...
Mean and Variance of: continuous uniform distribution, normal distribution, normal approximation for binomial and Poisson distributions, exponential distribution. and Continuous random variables Cumulative Distribution Function. In your own words summarize the above in three to five long sentences
Suppose that y has a normal distribution with mean 1 and variance 9. What is the...
Suppose that y has a normal distribution with mean 1 and variance 9. What is the probability that y is in the interval [.7, 2.5]?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT