Question

In: Math

(Please answer this question accuratelly THANKS) The following commands in R computes 5000 simulations of sample...

(Please answer this question accuratelly THANKS)

The following commands in R computes 5000 simulations of sample means of size 12 from a normal distribution with mean µ = 100 and standard deviation σ = 14. require

(fastR2) nsamplesum <- do(5000) * c(sample.mean=mean(rnorm(12,100,14)))

The following commands compute the approximate mean and standard deviation of the sample mean and plot the histogram giving the approximate distribution of the sample mean.

mean(∼ sample.mean, data=nsamplesum) sd(∼ sample.mean, data=nsamplesum) gf dhistogram(∼ sample.mean, data= nsamplesum, bins=20)

(a) Compare the approximate values of mean and standard deviation of the sample mean found above with the expected theoretical ones.

(b) Repeat the same simulation as above using now samples from a uniform distribution in the interval [−2, 4]. Also in this case, run a numerical test over 5000 simulations, compute mean and standard deviation of the sample mean, and compare it to the theoretical result.

Solutions

Expert Solution

a) Let X be a random variable having a normal distribution with mean and standard deviation

Let be the sample mean of a random sample of size n=12, selected from X. Using central limit theorem we know that has a normal distribution with mean and standard error of mean (standard deviation of )

Now we will use simulation to get 5000 values of and get the mean and standard deviations of these s and see if they match with waht we have above.

The following are the R commands (all statements starting with # are comments)

#install the package fastR2, if not already installed
install.packages('fastR2')

library(fastR2)

#set the random seed
set.seed(123)
#compute 5000 simulations of sample means (xbars) of size 12 from a normal distribution
#with mean µ = 100 and standard deviation σ = 14
nsamplesum <- do(5000) * c(sample.mean=mean(rnorm(12,100,14)))
#print the mean of sample means
mean(~ sample.mean, data=nsamplesum)
#print the standard deviation of sample means
sd(~ sample.mean, data=nsamplesum)
#plot the histogram of sample means
gf_dhistogram(~ sample.mean, data= nsamplesum, bins=20)

#get this output

The simulated mean of is 99.9918 compared to the theoretical value of 100

The simulated standard deviation of is 4.0658 compared to the theoretical value of 4.0415

We can see that the simulated values are close to the expected theoretical values

The following is the histogram giving the distribution of sample means

b) Let X be a random variable having a uniform in the interval [-2,4].

Using the standard results of uniform distribution we get

the mean of X as

and standard deviation of X as

Let be the sample mean of a random sample of size n=12, selected from X. Using central limit theorem we know that has a normal distribution with mean and standard error of mean (standard deviation of )

Now we will use simulation to get 5000 values of and get the mean and standard deviations of these s and see if they match with waht we have above.

The following are the R commands (all statements starting with # are comments)

#set the random seed
set.seed(123)
#compute 5000 simulations of sample means (xbars) of size 12 from a uniform distribution
#in the interval [-2,4]
nsamplesum <- do(5000) * c(sample.mean=mean(runif(12,min=-2,max=4)))
#print the mean of sample means
mean(~ sample.mean, data=nsamplesum)
#print the standard deviation of sample means
sd(~ sample.mean, data=nsamplesum)
#plot the histogram of sample means
gf_dhistogram(~ sample.mean, data= nsamplesum, bins=20)

# get this output

The simulated mean of is 1.0009 compared to the theoretical value of 1

The simulated standard deviation of is 0.4994 compared to the theoretical value of 0.50

We can see that the simulated values are close to the expected theoretical values

Get the following histogram showing the distribution of sample means


Related Solutions

HELLO, PLEASE ANSWER THE FOLLOWING QUESTION. IT WAS ASSIGNED WITH 2 PARTS. THANKS 42A) A company...
HELLO, PLEASE ANSWER THE FOLLOWING QUESTION. IT WAS ASSIGNED WITH 2 PARTS. THANKS 42A) A company uses the periodic inventory system and had the following activity during the current monthly period. November 1: Beginning inventory 112 Units @ $20 November 5: Purchased 112 Units @ $22 November 8: Purchased 62 Units @ $23 November 16: Sold 174 Units @ $105 November 19: Purchased 75 Units @ $25 Using the weighted-average inventory method, the company's ending inventory would be 42B. A...
This question requires using Rstudio. This is following commands to install and import data into R:...
This question requires using Rstudio. This is following commands to install and import data into R: > install.packages("ISLR") > library(ISLR) > data(Wage) The required data installed and imported, now this is description of the data: This dataset contains economic and demographic data for 3000 individuals living in the mid-Atlantic region. For each of the 3000 individuals, the following 11 variables are recorded: year: Year that wage information was recorded age: Age of worker maritl: A factor with levels 1. Never...
This question requires using Rstudio. This is following commands to install and import data into R:...
This question requires using Rstudio. This is following commands to install and import data into R: > install.packages("ISLR") > library(ISLR) > data(Wage) The required data installed and imported, now this is description of the data: This dataset contains economic and demographic data for 3000 individuals living in the mid-Atlantic region. For each of the 3000 individuals, the following 11 variables are recorded: year: Year that wage information was recorded age: Age of worker maritl: A factor with levels 1. Never...
This question requires using Rstudio. This is following commands to install and import data into R:...
This question requires using Rstudio. This is following commands to install and import data into R: > install.packages("ISLR") > library(ISLR) > data(Wage) The required data installed and imported, now this is description of the data: This dataset contains economic and demographic data for 3000 individuals living in the mid-Atlantic region. For each of the 3000 individuals, the following 11 variables are recorded: year: Year that wage information was recorded age: Age of worker maritl: A factor with levels 1. Never...
Please answer the last step for question 1. Answer it asap please. Thanks 1. Consider the...
Please answer the last step for question 1. Answer it asap please. Thanks 1. Consider the following data for three different samples from three different populations:Consider the following data for three different samples from three different populations: Sample 1 Sample 2 Sample 3 0 6 6 4 8 5 0 5 9 1 4 4 0 2 6 T = 5 T = 25 T = 30 G = 60 SS = 12 SS = 20 SS = 14 ∑X2...
Hi all, Can someone please answer this question. Please list all steps! Thanks! Consider the following...
Hi all, Can someone please answer this question. Please list all steps! Thanks! Consider the following projects: Cash Flows ($) Project C0 C1 D –10,300 20,600 E –20,300 35,525 Assume that the projects are mutually exclusive and that the opportunity cost of capital is 9%. a. Calculate the profitability index for each project. (Do not round intermediate calculations. Round your answers to 2 decimal places.) Project Profitability Index D E b-1. Calculate the profitability-index using the incremental cash flows. (Do...
Hi all, Can someone please answer this question. Please list steps! Thanks! Consider the following cash...
Hi all, Can someone please answer this question. Please list steps! Thanks! Consider the following cash flows: Cash Flows ($) C0 C1 C2 −8,450 6,200 21,400 a. Calculate the net present value of the above project for discount rates of 0, 50, and 100%. (Do not round intermediate calculations. Round your answers to the nearest whole dollar amount.) NPV @ 0% $ NPV @ 50% $ NPV @100% $ b. What is the IRR of the project? (Do not round...
Please answer the question ASAP thanks In view of the success of the B2B enterprise, to...
Please answer the question ASAP thanks In view of the success of the B2B enterprise, to analyze the characteristics of the B2B system in the system planning and pattern management, and summarizes the successful elements of the model.
PLEASE ANSWER JUST QUESTION i, j, l. Thanks Confidence   interval   for   a   mean   and   one-sample   t-test.  ...
PLEASE ANSWER JUST QUESTION i, j, l. Thanks Confidence   interval   for   a   mean   and   one-sample   t-test.   As   the world   warms,   the   geographic   ranges   of   species   might   shift   toward   cooler   areas.   Chen   et   al. (2011)   studied   recent   changes   in   the   highest   elevation   at   which   species   occur.   Typically, higher   elevations   are   cooler   than   lower   elevations.   Below   are   the   changes   in   highest elevation   for   31   taxa,   in   meters,   over   the   late   1900s   and   early   2000s.   (Many   taxa   were surveyed,   including   plants,   vertebrates,   and  ...
Please answer the question below, thanks! 1. Suppose a company has estimated the following cash flows...
Please answer the question below, thanks! 1. Suppose a company has estimated the following cash flows in each of the next three years for operations in various countries. Year New Zealand Japan 1 160 NZD 16,415 JYP 2 174 NZD 17,844 JYP 3 181 NZD 18,401 JYP If the USD/JPY is 100 and the USD/NZD is 110, what are the expected cash flows in each of the next three years? . 2. If the Euro ask price is $1.35 and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT