Zookal
Zookal

We’d love to hear any feedback or comment from you!

© 2011-2021 Zookal Pty Ltd

View question and answer

From our collection of questions and answers
Engineering · Computer Science
Question details

PLEASE PROVIDE CODE IN R

(a) Given the linear model E(%)-30 + ßir, and a vector of observation weights w-u, . . . , wny, the weighted least squares estimate of the regression coefficient 3 (Bo B1) is where t1 X- 1 rn is the design matrix and 01 0 n is the diagonal matrix containing the weights. (a) Write a function weighted ls which takes the vectors (NumPy arrays) x, y, and w as arguments and which 2 marks] S) Suppose we want to predict the response for a new observation, for which the covariate takes the value ro- returns the weighted least squares estimate β. The predicted value of the response is thenwhere B predict.wls, which takes x, y, w and x0 as arguments, and returns the least squares prediction ýo (Bo, BY is the coefficient estimate obtained using the function weighted.1s. Write a function Your function should first call the function weighted-ls to compute 3 (from x, y and w) and then compute 1 mark] o using equation (1) (b) Locally linear regression is a method for fitting a smooth function f(.) to data points (riyi), where x=(xi, rn), is the covariate and y - (vi,...,yn) is the response variable. In locally linear regression the weighted lin- ear model is used to construct a non-linear method for regression. This is done by computing a different set of weights for each value of.ro. Given.ro and a parameter ρ (which controls how smooth the fitted function will be). the set of weights w (wi,..., wn) is computed using i.e. observations close to ro become larger weights. Write a function compute weights which takes the vector x, the new observation x0 (a single number), and the parameter rho as arguments, and which computes the weights w. 1 mark]Assuming that your data lives in a data frame mcycle and that your poredictions are called yhat you can then plot the data and the fitted regression function using the commands. import matplotlib.pyplot as plt plt plot (mcycle[times], mcycle[ accel, o) plt plot (x0, yhat) plt.show ()

Answer
Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.

Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.