Question

In: Math

Please do this task by R. a) Revise the simulation shown in the lecture with the...

Please do this task by R.

a) Revise the simulation shown in the lecture with the aim of constructing the empirical sampling distribution of beta_hat, based on 5000 trials.

b) According to the lecture, the mean of that histogram is supposed to be approximately equal to the true slope. Is it? Show code.

c) According to the lecture, the standard deviation of that histogram is supposed to be approximately equal to sigma_eps/sqrt(Sxx). Is it? Show code.

d) According to the lecture, the distribution of the beta_hat is supposed to be normal with certain parameters. Use qqnorm() and abline() to confirm that it is normal.

not sure if this help or not,

n = 10

n.trial = 64

x = c(1:n)

y_true = 10 + 2*x

sigma_eps = 15

par(mfrow=c(8,8),mar=c(0,0,0,0))

set.seed(123)

for(trial in 1:n.trial){

y_obs = y_true + rnorm(n,0,sigma_eps)

lm.1 = lm(y_obs ~ x)

plot(x, y_obs)

abline(10,2, col=2)

abline(lm.1, col=4)

}

Solutions

Expert Solution

a) Observe that to change the simulation trials to 5000 times, we just need to change the n.trial variable. Changing it's value to 5000 will ensure that in the given code. Also the for loop should be changed to the following:

This will store all the slopes in the beta vector.

After this use the hist function on beta to get the following result:

b) Use mean() function on beta to get the mean of this histogram which in this case is 1.969032, which is quite close to the actual slope.

c) Use sd() function on beta to get the standard deviation of this histogram which in this case is 1.642933, where

so the obtained value is quite close to the theoretical value.

d) The qqnorm and abline results are given below:

Observe that the Q-Q line passes almost exactly through the Q-Q plot. Also observe that the middle line drawn through abline lies exactly in the middle of the histogram and the other 2 lines are standard deviations away from the mean, which covers almost all of data points. Hence, we can say that the coefficients are normally distributed.


Related Solutions

Revise the data in your worksheet to reflect the results for the subsequent period as shown...
Revise the data in your worksheet to reflect the results for the subsequent period as shown below: A B C D E F 1 Chapter 8: Applying Excel 2 3 Data 4 Exhibit 8-8: Standard Cost Card 5 Inputs Standard Quantity Standard Price 6 Direct materials 3.0 pounds $4.00 7 Direct labor 0.50 hours $22.00 per hour 8 Variable manufacturing overhead 0.50 hours $6.00 per hour 9 10 Actual results: 11     Actual output 2,190 units 12     Actual variable manufacturing overhead...
Stimulation (Please read the simulation before answering the questions . Please do not scan your answer,...
Stimulation (Please read the simulation before answering the questions . Please do not scan your answer, type please) Hey Ben. You’re getting an admission in the next 15 minutes coming from the outpatient clinic. BEN: Okay, what can you tell me about this client? JAN: Well, Susan Choi is 33 years old. (PATIENT) She’s been followed for depression over the past six months and is being admitted for acute mania. She is on administrative leave from her employment as a...
Please do these questions in the R language 1. Load the cars dataset into R. It...
Please do these questions in the R language 1. Load the cars dataset into R. It is a built-in dataset. 2. Do an str() to determine the number of observations and variables. Enter your answer as a comment. 3. Plot speed on x axis and distance on y axis. 4. Find the correlation between speed and distance. What does the magnitude and sign indicate? Enter your answer as a comment. 5. Build a linear regression model with speed as the...
TASK: ( answers should be computerized and in details - please do not copy and paste...
TASK: ( answers should be computerized and in details - please do not copy and paste - about 1500 words ) Select an organization of your choice and carry out the following tasks. Conduct a research on the marketing and promotional strategies of the organization selected. Your Report should include the following: 1. Introduction 2. Summarize the various promotional strategies used by the organization in implementing an Integrated Marketing Strategy. Identify the risks associated with promotional campaigns and discuss how...
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 ?
Fill in the blanks in the following simulation for R, which finds the approximate variance of...
Fill in the blanks in the following simulation for R, which finds the approximate variance of N, the number of rolls of a die needed to get the face having just one dot. onesixth <- 1/6 sumn <- 0 sumn2 <- 0 for (i in 1:10000) { n <- 0 while(TRUE) { ________________________________________ if (______________________________ < onesixth) break } sumn <- sumn + n sumn2 <- sumn2 + n^2 } approxvarn <- ____________________________________________ cat("the approx. value of Var(N) is ",approxvarn,"\n")
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...
preform a Monte Carlo simulation in R to generate the probability distribution of the sum of...
preform a Monte Carlo simulation in R to generate the probability distribution of the sum of two die (for example 1st die is 2 and second die is 3 the random variable is 2+3=5). The R-script should print out (display in R-studio) or have saved files for the following well labeled results: 1. Histrogram or barchart of probability distribution 2. Mean of probability distribution 3. Standard deviation of probability distribution
Please provide an example of a Monte Carlo simulation model (and explain). Your simulation example should...
Please provide an example of a Monte Carlo simulation model (and explain). Your simulation example should be able to: Tackle a wide variety of problems using simulation Understand the seven steps of conducting a simulation Explain the advantages and disadvantages of simulation Develop random number intervals and use them to generate outcomes Understand alternative computer simulation packages available Explain the different type of simulations Explain the basic concept of simulation
Please do this question in R and show the code too, please. The alternating current (AC)...
Please do this question in R and show the code too, please. The alternating current (AC) breakdown voltage of an insulating liquid indicates its dielectric strength. The article “Testing Practices for the AC Breakdown Voltage Testing of Insulation Liquids” (IEEE Electrical Insulation Magazine, 1995: 21–26) gave the accompanying sample observations on breakdown voltage (kV) of a particular circuit under certain conditions. 62 50 53 57 41 53 55 61 59 64 50 53 64 62 50 68 54 55 57...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT