Question

In: Statistics and Probability

Q3. (This question is based in R) Now use the simulation ("X = rnorm(1000, mean =...

Q3. (This question is based in R)
Now use the simulation ("X = rnorm(1000, mean = 10, sd = 2)", "Y = rnorm(1000, mean = 5, sd = 3)") to estimate the distribution of X+Y and create confidence intervals.

A) Form a set of Xs and Ys by repeating the individual experiment for B = 2000 times, where each experiment has n = 1000 samples. You may want to write a for loop and create two matrices "sample_X" and "sample_Y" to save those values. 

B) Calculate the mean of X+Y for each experiment and save it to a vector which has a length of B, and plot a histogram of these means. 

C) Now as we have a simulated sampling distribution of X+Y, calculate the 95% confidence interval for mean of X+Y (this can be done empirically). 

D) In the above example, we have fixed the sample size n and number of experiments B. Next, we want to change B and n, and see how the confidence interval will change. Please write a function to create confidence intervals for any B and n. 

E) Suppose the sample size n varies (100, 200, 300, .... , 1000) (fix B=2000) and the number of experiments B varies (1000, 2000, ... , 10000) (fix n=500). Plot your confidence intervals to compare the effect of changing the sample size n and changing the number of simulation replications B. What do you conclude? (Hint: Check function errbar() in Hmisc package for plot - library(Hmisc))

fix n, B varies

fix B, n varies

Solutions

Expert Solution

Solved in R with code and output shown below


Related Solutions

This is a question answered by R. **In this problem, we'll use simulation to think about...
This is a question answered by R. **In this problem, we'll use simulation to think about survey sampling. Suppose I want to plan a survey to learn what percentage of students prefer coffee to tea.** a. **Let *X* be the number of students in my sample that prefer coffee. If I survey *n* students, and the true proportion of students that prefer coffee is *p*, then we can model *X* as a Binomial(*n*, *p*) random variable. If I survey ten...
Consider the hallmark question below A) Use simulation with 1000 replications to determine the distribution of...
Consider the hallmark question below A) Use simulation with 1000 replications to determine the distribution of profit for 130 unit order quantity. CHART IT. B) Use one way data table to determine the expected profit for each of order quantities 100, 110, 120, 130, and 140. Determine the optimal order quantity. Hallmark sells “personal expression” cards and gifts worldwide through either its own stores or other retailers. Most products are single runs. A typical problem Hallmark faces is as follows:...
R Simulation: For n = 1000, simulate a random sample of size n from N(0,1). Use...
R Simulation: For n = 1000, simulate a random sample of size n from N(0,1). Use the generated data to give an approximation to the critical values when α = 0.01,0.05,0.1, and compare them with the theoretical values zα/2. Repeat with n = 10,000 to get a better approximation. Please use Commands quantile( ) or qnorm( ) or both.
student_id=100 set.seed(student_id) Group1=round(rnorm(15,mean=10,sd=4),2) Group2= round(rnorm(12,mean=7,sd=4),2) For this question you are not allowed to use the lm()...
student_id=100 set.seed(student_id) Group1=round(rnorm(15,mean=10,sd=4),2) Group2= round(rnorm(12,mean=7,sd=4),2) For this question you are not allowed to use the lm() command in R or the equivalent of lm() in python or other software. If you want to use a software, only use it as a calculator. So if you are using R, you may only use mean(), sum(), qt() and of course +,-,*,/. (Similar restrictions for Python, excel or others). Consider all the 27 numbers printed under Group1 and Group2 as your y values,...
what does it mean to treat a value as fixed in simulation in r ?
what does it mean to treat a value as fixed in simulation in r ?
1) For your sample, use R to find the mean of x, the mean of y,...
1) For your sample, use R to find the mean of x, the mean of y, the standard deviation of x, the standard deviation of y, and the correlation between x and y. (You must give R code for credit.) > set.seed(0003653838) > x=rnorm(500) > y=2*x+rnorm(500) > Xbar=mean(x) > Xbar [1] 0.0712552 > Ybar=mean(y) > Ybar [1] 0.2370446 > sdx=sd(x) > sdx [1] 0.9841084 > sdy=sd(y) > sdy [1] 2.277837 > corxy=cor(x,y) > corxy [1] 0.9040743 2) Find the equation...
Please use R-Studio to answer the following question. I mentioned that dnorm(x, mean, sd) doesn’t give...
Please use R-Studio to answer the following question. I mentioned that dnorm(x, mean, sd) doesn’t give the probability of being exactly equal to x. So what does it give? It gives you the height of the normal curve at that x. Plot the graph of a normal random variable with mean 50 and standard deviation 10. Note you will have to create range of xvalues between 0 to 100. Then find the probability using dnorm() then use plot() command
(Use R Programming to Code) Use the Monte Carol simulation to estimate the probability that all...
(Use R Programming to Code) Use the Monte Carol simulation to estimate the probability that all six faces appear exactly once in six tosses of fair dice.
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....
Q3. Consider the matrix A . Use R statistical software to determine the eigenvalues and normalized...
Q3. Consider the matrix A . Use R statistical software to determine the eigenvalues and normalized eigenvectors of A, trace of A, determinant of A, and inverse of A. Also determine the eigenvalues and normalized eigenvectors of A-1. Your answer should include your R code (annotated with comments) and a hand-written or typed summary of the answers from the R output.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT