EssayGhost Assignment代写,Essay代写,网课代修,Quiz代考




您的位置: 主页 > 编程案例 > R语言代写 >
R语言代写 - BTRY 4030 Homework 5 代写R语言,编程代写
发布时间:2021-08-03 23:36:11浏览次数:
BTRY 4030 Homework 5 Q代做homework | R语言代写 | 统计代写 , 这是一个的homework代写的题目,涉及R语言代写和统计代写Put Your Name and NetID HereDue Tuesday, December 4, 2018You may either respond to the questions below by editing the hw5_2018_q1.Rmd to include your answersand compiling it into a PDF document, or by handwriting your answers and scanning these in.You may discuss the homework problems and computing issues with other students in the class. However, youmust write up your homework solution on your own. In particular, do not share your homework RMarkdownfile with other students.Here we will add one more deletion diagnostic to our arsenal. When comparing two possible models, we oftenwant to ask Does one predict future data better than the other? One way to do this is to divide your datainto two collections of observations( X, y)and( X, y), say. We use( X, y)to obtain a linear regressionmodel, with parameters and look at the prediction error ( y2 )T2 ).This is a bit wasteful you could use( X, y)to improve your estimate of. However, we can assess howwell this type of model does (for these data) as follows:For each observation ii. Remove( x i,yi )from the data and obtain( i )from the remaining n 1 data points.ii. Use this to make a prediction y ( i ) i= xTi( i )Return the cross validation error CV =ni =( yi y ( i ) i2This can be used to compare a models that use different covariates, for example; particularly when the modelsare not nested. We will see an example of this in Question 2.Here, we will find a way to calculate CV without having to manually go through removing observations oneby one.a.We will start by considering a separate test-set. As in the midterm, imagine that we have X 2 = X 1 , butthat the errors that produce y 2 are independent of those that produce y 1. We estimate |using( X 1 , y 1 ): = ( XT1X 1 ) 1T1y. Show that the in-sample average squared error,( y 1 X 1 )T( y 1 X 1 ) /n , isbiased downwards as an estimate of , but the test-set average squared error,( y 2 X 2 )T( y 2 X 2 ) /n ,is biassed upwards. (You may find the midterm solutions helpful.)b.Suppose that = 0, that is the final column of Xhas no impact on prediction. Show that the test seterror is smaller if we remove the final column from each of Xand Xthan if we dont. (This makesusing a test set a reasonable means of choosing what covariates to include. )c. Now we will turn to cross validation. Using the identity( i ) 1 hT 1 efrom class, to obtain an expression for the out of sample prediction xTi( i )in terms of x i , yi , and hiionly.d.Hence obtain an expression for the prediction error yi xTi( i )using only yi , y i and hii. You may wantto check this empirically using the first few entries of the data used in Question 2.e. Show that the over-all CV score can be calculated fromni = e2i(1 h2that is, without deleting observations, and only requiring the leverages hii.