Testing_Correlations

.m

School

University of Texas, San Antonio *

*We aren’t endorsed by this school

Course

1173

Subject

Computer Science

Date

Dec 6, 2023

Type

m

Pages

2

Uploaded by ChiefEnergyOstrich21 on coursehero.com

%% Example 1 load("DaphneIsland.txt"); %% Example 2 ChildBeakSize = DaphneIsland(:,1); MotherBeakSize = DaphneIsland(:,2); FatherBeakSize = DaphneIsland(:,3); [h1, p1, c1] = ttest(FatherBeakSize, 10); fprintf(['Do the Father Beak Sizes average 10 mm?\n\t' ... 'h = %g, p = %g, ci = [%g, %g]\n'], h1, p1, c1); %% Exercise 1 ChildBeakSize = DaphneIsland(:,1); MotherBeakSize = DaphneIsland(:,2); FatherBeakSize = DaphneIsland(:,3); [h2, p2, c2] = ttest(MotherBeakSize, 10); fprintf(['Do the Mother Beak Sizes average 10 mm?\n\t' ... 'h = %g, p = %g, ci = [%g, %g]\n'], h2, p2, c2); % Null Hypothesis: Mother Beak sizes average 10mm % Alternate Hypothesis: Mother Beak size are NOT 10mm % Significance Level: .09 or 9% % The null hypothesis is accepeted %% Example 3 [h3, p3, c3] = ttest2(MotherBeakSize,FatherBeakSize); fprintf(['Do the Mother and Father have similar Beak Sizes?\n\t'... 'h = %g, p = %g, ci = [%g, %g]\n'], h3, p3, c3); %% Exercise 2 [h4, p4, c4] = ttest2(MotherBeakSize,ChildBeakSize); fprintf(['Do the Mother and Father have similar Beak Sizes?\n\t'... 'h = %g, p = %g, ci = [%g, %g]\n'], h4, p4, c4); % Null Hypothesis: Average Mother and Child Finches beaks are similar % Alternate Hypothesis: Average Mother and Child Finches Beak sizes are NOT similar % Significance Level: .10 or 10% % The null hypothesis is accepeted %% Example 4 parent = mean(DaphneIsland(:, 2:3), 2); % Average the parent beak sizes pCorr = corr(parent, ChildBeakSize); fprintf('Parent-child beak correlation: %g\n', pCorr) %% Exercise 3 Mother = mean(DaphneIsland(:, 2:3), 1); % Average the mother beak sizes pCorr = corr(MotherBeakSize, ChildBeakSize); fprintf('Mother-child beak correlation: %g\n', pCorr) Father = mean(DaphneIsland(:, 2:3), 1); % Average the father beak sizes pCorr = corr(FatherBeakSize, ChildBeakSize); fprintf('Father-child beak correlation: %g\n', pCorr)
% The correlation value is greater than .5. % The Mother-Child Beak size is higher than the Father-Child Beak % size, indicating that there is a positive correlation as to Mother-Child beak sizes and to Father-Child Beak sizes. %% Example 5 tString = ['Daphne island finches (corr = ', num2str(pCorr) ')']; figure('Name', tString) % Put title on the window plot(parent, ChildBeakSize, 'ko') % Plot a scatter plot xlabel('Parent beak size (mm)'); % Label the x-axis ylabel('Child beak size (mm)'); % Label the y-axis title(tString); % Put title on the graph %% Example 6 % Keep the Figure from Example 4 open on your desktopuse menu bar on the % figure to complete the following. % Make the plot editable. (Click Tools->Edit Plot from the Figure Window % menubar.) % Add a linear fit line. (Click Tools ->Basic Fitting from the Figure % Window menubar. Click the linear checkbox in the Basic Fitting dialog box % and close.) % Save the figure as a BeakSize.fig (Click File ->Save ->File name: % BeakSize -> Save) %% Example 7 pPoly = polyfit(parent, ChildBeakSize, 1); % Linear fit of parent vs child fprintf('Model: child = %g*parent + %g\n', pPoly(1), pPoly(2)) %% Exercise 4 pPoly2 = polyfit(MotherBeakSize, ChildBeakSize, 1); % Linear fit of parent vs child fprintf('Model: child = %g*mother + %g\n', pPoly2(1), pPoly2(2)) %% Example 8 pPred = polyval(pPoly, parent); % Find parent-child relationship %% Example 9 pError = ChildBeakSize - pPred; % Actual - predicted by parent's size %% Example 10 pMSE = mean(pError.*pError); fprintf('Mean squared prediction error: %g\n', pMSE); %% Example 11 pRMS = sqrt(pMSE); fprintf('RMS prediction error: %g mm\n', pRMS)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help