Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use a MATLAB function crossv.m that carries out cross-validation to determine the mean and standard deviation of the true data points from the predicted lines

Use a MATLAB function crossv.m that carries out cross-validation to determine the mean and standard deviation of the true data points from the predicted lines for a polynomial of a specified order, in y vs. x. (For input arguments, use the variables x, y and degree of polynomial.) Test the function on the age vs. depth data used in agedepth.txt. Provide the published code, and run it on the age vs. depth data for the polynomials of order 1 through 6. What conclusions about the goodness-of-fits do you draw (for increasing order of polynomial), and why --------------crossv.m-------------- function [avgerr, avgdev]= crossv(x,y, norder) % crossv function to perform crossvalidation of y vs. x (inputs) % inputs: x, y (both are single-variable vectors the same length), norder % norder is the order of the polynomial for fitting % outputs: average and standard deviation of predicted values of y from x % (avgerr, avgdev), as based on cross-validation % GMA, Oct. 2008, based on a MATLAB Recipes routine by Trauth n = length(x); for i = 1 : n % Define temporary variables j_x and j_y j_x = x; j_y = y; % Eliminate the i-th data point j_x(i) = []; j_y(i) = []; % Compute regression line from the n-1 data points p(i,:) = polyfit(j_x,j_y,norder); plot(x,polyval(p(i,:),x),'r'); hold on % Store the regression result and errors in predy and prederr predy(i) = polyval(p(i,:),x(i)); prederr(i) = predy(i) - y(i); end avgerr = mean(prederr); avgdev = std(prederr); 

------------------------------------------------agedepth.txt--------------------------------------------------------

 5.7496426e-01 -3.3873585e+00 1.1900810e+00 2.6074261e+00 1.7792352e+00 7.6639203e-03 2.2667996e+00 1.9777412e+01 3.2289751e+00 1.9460857e+01 4.0175282e+00 4.7864249e+01 5.4261635e+00 1.5663317e+01 5.4617632e+00 2.8686956e+01 6.5791060e+00 4.8130676e+01 7.1331107e+00 4.0977152e+01 8.1814463e+00 5.8764541e+01 8.6888108e+00 4.0716317e+01 9.4808290e+00 5.9144081e+01 9.5638885e+00 7.5251810e+01 9.9660919e+00 5.9726624e+01 1.0737034e+01 7.0804379e+01 1.1249168e+01 4.4681634e+01 1.1910960e+01 7.4737244e+01 1.1924943e+01 6.3437347e+01 1.1943416e+01 7.4103329e+01 1.2332423e+01 6.7087385e+01 1.2524693e+01 7.3214110e+01 1.3400077e+01 7.6690174e+01 1.5091028e+01 6.8961248e+01 1.5822464e+01 7.0582863e+01 1.6299041e+01 8.8108010e+01 1.6589485e+01 7.7996858e+01 1.7965035e+01 1.1009416e+02 1.8179787e+01 1.1946161e+02 1.9122448e+01 1.2067323e+02

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions