please can you solve the questions on Matlab language a2_00000000.m…
Question Answered step-by-step please can you solve the questions on Matlab language a2_00000000.m… please can you solve the questions on Matlab language Image transcription textThe subject matter for this assignment is ?nancial data,speci?cally global prices of a selection of basic goods.Coding for this requires multiple uses of linear … Show more… Show moreImage transcription textPreliminary: The Data This assignment uses data that theinstructor gathered from the U.S. Federal Reserve Bank of St.Louis Economic Data (FRED) website. The data are… Show more… Show moreImage transcription textFor example, if there were three variables in the data set, thefunction a2,0 O O O O O O 0 would return a matrix such as [ O . lO . 2 O . 3] The starter code will also return the ind… Show more… Show moreImage transcription text1.3: Discussing The Results Your discussion should compare andcontrast your numerical results and any observation you haveon, for example, the merits of using the second-bes… Show more… Show moreImage transcription text2.2: Fold Selection There are many ways to select folds, includingalgorithmic selection and random selection. You must describeand verbally defend your choice. Some choices req… Show more… Show morea2_00000000.mfunction [rmsvars lowndx rmstrain rmstest] = a2_00000000% [RMSVARS LOWNDX RMSTRAIN RMSTEST]=A3 finds the RMS errors of% linear regression of the data in the file “GOODS.CSV” by treating% each column as a vector of dependent observations, using the other% columns of the data as observations of independent varaibles. The% individual RMS errors are returned in RMSVARS and the index of the% smallest RMS error is returned in LOWNDX. For the variable that is% best explained by the other variables, a 5-fold cross validation is% computed. The RMS errors for the training of each fold are returned% in RMSTEST and the RMS errors for the testing of each fold are% returned in RMSTEST.%% INPUTS:% none% OUTPUTS:% RMSVARS – 1xN array of RMS errors of linear regression% LOWNDX – integer scalar, index into RMSVALS% RMSTRAIN – 1×5 array of RMS errors for 5-fold training% RMSTEST – 1×5 array of RMS errors for 5-fold testing filename = ‘goods.csv’; [rmsvars lowndx] = a2q1(filename); [rmstrain rmstest] = a2q2(filename, lowndx)endfunction [rmsvars lowndx] = a2q1(filename)% [RMSVARS LOWNDX]=A2Q1(FILENAME) finds the RMS errors of% linear regression of the data in the file FILENAME by treating% each column as a vector of dependent observations, using the other% columns of the data as observations of independent varaibles. The% individual RMS errors are returned in RMSVARS and the index of the% smallest RMS error is returned in LOWNDX. %% INPUTS:% FILENAME – character string, name of file to be processed;% assume that the first row describes the data variables% OUTPUTS:% RMSVARS – 1xN array of RMS errors of linear regression% LOWNDX – integer scalar, index into RMSVALS % Read the test data from a CSV file; find the size of the data % % % % STUDENT CODE GOES HERE: REMOVE THIS COMMENT % % THEN READ THE FILE SPECIFIED BY THE INPUT ARGUMENT % % % Compute the RMS errors for linear regression % % % % STUDENT CODE GOES HERE: REMOVE THE NEXT 2 LINES AND THIS COMMENT % % THEN PERFORM THE COMPUTATIONS % % rmsvars = 0.1*(1:16); lowndx = 1; % Find the regression on your choice of standardized % or unstandardized variables % % % % STUDENT CODE GOES HERE: REMOVE THIS COMMENT % % THEN PERFORM THE COMPUTATIONS % % % Plot the results % % % % STUDENT CODE GOES HERE: REMOVE THIS COMMENT % % THEN PLOT THE RESULTS % %endfunction [rmstrain rmstest] = a2q2(filename,lowndx)% [RMSTRAIN RMSTEST]=A3Q2(LOWNDX) finds the RMS errors of 5-fold% cross-validation for the variable LOWNDX of the data in the file% FILENAME. The RMS errors for the training of each fold are returned% in RMSTEST and the RMS errors for the testing of each fold are% returned in RMSTEST.%% INPUTS:% FILENAME – character string, name of file to be processed;% assume that the first row describes the data variables% LOWNDX – integer scalar, index into the data% OUTPUTS:% RMSTRAIN – 1×5 array of RMS errors for 5-fold training% RMSTEST – 1×5 array of RMS errors for 5-fold testing % Read the test data from a CSV file; find the size of the data % % % % STUDENT CODE GOES HERE: REMOVE THIS COMMENT % % THEN READ THE FILE SPECIFIED BY THE INPUT ARGUMENT % % % Create Xmat and yvec from the data and the input parameter, % accounting for no standardization of data % % % % STUDENT CODE GOES HERE: REMOVE THIS COMMENT % % THEN ASSIGN THE VARIABLES FROM THE DATASET % % % Compute the RMS errors of 5-fold cross-validation % % % % STUDENT CODE GOES HERE: REMOVE THE NEXT 2 LINES AND THIS COMMENT % % THEN PERFORM THE COMPUTATIONS % % rmstrain = 0.5*ones(1,5); rmstest = 0.6*ones(1,5);endfunction [rmstrain,rmstest]=mykfold(Xmat, yvec, k_in)% [RMSTRAIN,RMSTEST]=MYKFOLD(XMAT,yvec,K) performs a k-fold validation% of the least-squares linear fit of yvec to XMAT. If K is omitted,% the default is 5.%% INPUTS:% XMAT – MxN data vector% yvec – Mx1 data vector% K – positive integer, number of folds to use% OUTPUTS:% RMSTRAIN – 1xK vector of RMS error of the training fits% RMSTEST – 1xK vector of RMS error of the testing fits % Problem size M = size(Xmat, 1); % Set the number of folds; must be 1


