EE263 Homework 41. Fitting a model for hourly temperature.You are given a set of temperature measure-ments (in degrees C),yt∈R,t= 1, . . . , N, taken hourly over one week (soN= 168). Anexpert says that over this week, an appropriate model for the hourly temperature is a trend(i.e., a linear function oft) plus a diurnal component (i.e., a24-periodic component):ˆyt=at+pt,wherea∈Randp∈RNsatisfiespt+24=pt, fort= 1, . . . , N-24.We can interpreta(which has units of degrees C per hour) as the warming or cooling trend (fora >0ora <0,respectively) over the week.a) Explain how to finda∈Randp∈RN(which is24-periodic) that minimize the RMSvalue ofy-ˆy.b) Carry out the procedure described in part (a) on the data set found intempfit_data.json.Give the value of the trend parameterathat you find. Plot the modelˆyand the measuredtemperaturesyon the same plot. (The matlab code to do this is in the data file, butcommented out.)c)Temperature prediction.Use the model found in part (b) to predict the temperature forthe next24-hour period (i.e., fromt= 169tot= 192). The filetempfit_data.jsonalso contains a24long vectorytomwith tomorrow’s temperatures.Plot tomorrow’stemperature and your prediction of it, based on the model found in part (b), on the sameplot. What is the RMS value of your prediction error for tomorrow’s temperatures?2. Leave-one-out cross-validation.Consider the standard measurement setupy=Ax+,wherex∈Rnis an unknown vector of parameters,y∈Rmis a vector of measurements,A∈Rm×nis a known measurement matrix, and∈Rmis an unknown error vector.Weassume thatm > n, so there are strictly more observations than unknown parameters. Letˆx∈Rnbe the least-squares estimate ofx, andr=y-Aˆxbe the vector of least-squaresresiduals. The squared fitting error,∑mi=1r2i, gives an overly optimistic estimate of how wellthe model describes the data. A more accurate estimate of the performance of the model canbe obtained using leave-one-out cross-validation (LOOCV). The LOOCV squared fitting erroris obtained as follows.•Let˜Ai∈R(m-1)×nbe the matrix obtained by removing theith row fromA,•˜yi∈Rm-1be the vector obtained by removing theith component fromy,•˜xi=˜A†i˜yi∈Rnbe the least-squares estimate obtained using all of the measurementsexcept for theith measurement, and•˜ri=yi-Ai*˜xi∈Rbe the fitting error for theith measurement using˜xias the estimateofx.

#### You've reached the end of your free preview.

Want to read all 5 pages?

- Spring '19
- Hassan Kasfy