Está en la página 1de 10

Course Number: CEE 384

Section Number: 70639


Semester: Fall 2015
Project Number: MATLAB Project 7
Group Number: ASFMAD
Group members and their contributions:
Abdullah Aldhaheri 33%
Ahmad Mohammed Aldhaheri 34%
Daeej Aldeehani 33%
Date: 11/16/2015

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:

Resuting Linear equation:

Problem 2: Adequacy of linear regression model:

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].

Calculate the coefficient of the determination, .

Plot the residuals against the predictable variable, x.

Provide a histogram plot of the residuals

Perform the autocorrelation check.

Discuss your findings and interpret the results.

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]

Coeffiecients of determination are found by the following formula on the matlab:

Then the coeffiecients are:

Plot the residuals against the predictable variable, x.

Provide a histogram plot of the residuals

Perform the autocorrelation check.

mod = lm(prices[,1] ~ prices[,2])


res = mod$res
n = length(res)
mod2 = lm(res[-n] ~ res[-1])
summary(mod2)

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)')

Calculate the residuals.

res = y - y2;

Plot the residuals.

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')

También podría gustarte