Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Problem 1:
Use the ployfit command on MATLAB to calculate the linear regression models for group Ws path
and the group Ns path. Display the resulting linear equations in the command window. Use he vpa
command or the fprintf command to control the display precision. Plot the regression lines and
original data in the same graph.
Code:
load running
x = hwydata(:,14);
y = hwydata(:,4);
format long
b1 = x\y
yCalc1 = b1*x;
scatter(x,y)
hold on
plot(x,yCalc1)
xlabel('group N')
ylabel('Group W')
title('Linear Regression Relation Between Group N and Group W')
grid on
Output:
Apply the following to check the adequacy of the linear regression models for both runners.
Visually compare the regression lines and the original data points (figure plotted in Problem 1.
Discuss your observations.
Calculate the standard error of estimate and determine if 95% of he scaled residuals are
within the range [-2, 2].
Solution:
By comparing the regression line and original data points shows that both are almost
approaches each other. The data points are almost linearly approaches to the regression line.
The original data points are random but the regression line is straight and provide accurate data
from the straight line.
The standard error of estimate shows 97% of clear results and the residuals are within the
range [2,2]
mod2 is a linear regression of the time t error, t, against the time t1 error, t1. if the
coefficient for res[-1] is significant, you have evidence of autocorrelation in the residuals.
Problem 3:
For the runner in the group W, estimate a higher order polynomial regression model. You may try
different orders for the polynomials and report the best model. Apply visual comparison, error of
estimate, scaled residuals and the coefficient of determination as the primary performance indicators.
You may consult MATLAB help documentation and use the MATLAB Curve Fitting app to perform the
task. Include figures, tables, as well as discussions wherever appropriate in your final report.
Code:
t = [0 0.3 0.8 1.1 1.6 2.3];
y = [0.6 0.67 1.01 1.35 1.47 1.25];
plot(t,y,'o')
title('Plot of y Versus t')
t2 = 0:0.1:2.8;
y2 = polyval(p,t2);
figure
plot(t,y,'o',t2,y2)
title('Plot of Data (Points) and Model (Line)')
res = y - y2;
figure, plot(t,res,'+')
title('Plot of the Residuals')
p5 = polyfit(t,y,5)
Evaluate the polynomial at t2 and plot the fit on top of the data in a new figure window.
y3 = polyval(p5,t2);
figure
plot(t,y,'o',t2,y3)
title('Fifth-Degree Polynomial Fit')