Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a. Write an R function to: (i) simulate n data points from the model, y = a + bx + error, with data points x

a. Write an R function to:

(i) simulate n data points from the model, y = a + bx + error, with data points x uniformly sampled from the range (0, 100) and with errors drawn independently from the normal distribution with mean 0 and standard deviation σ;

(ii) fit a linear regression to the simulated data; and

(iii) make a scatterplot of the data and fitted regression line. Your function should take as arguments, a, b, n, σ, and it should return the data, print out the fitted regression, and make the plot. Check your function by trying it out on some values of a, b, n, σ.

b. Repeat the example , varying the number of data points, n. What happens to the parameter estimates and uncertainties when you increase the number of observations?

c. Simulation study: Perform the previous exercise more systematically, trying out a sequence of values of n, for each simulating fake data and fitting the regression to obtain estimate and uncertainty (median and mad sd) for each parameter. Then plot each of these as a function of n and report on what you find

Step by Step Solution

3.43 Rating (162 Votes )

There are 3 Steps involved in it

Step: 1

Requ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probability With Applications and R

Authors: Robert P. Dobrow

1st edition

1118241257, 1118241258, 978-1118241257

More Books

Students also viewed these Mathematics questions

Question

understand the limitations of classic models of job design.

Answered: 1 week ago

Question

Calculate the missing values

Answered: 1 week ago