Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use least-squares regression to fit the following function to the given data and

ID: 3064201 • Letter: U

Question

Use least-squares regression to fit the following function to the given data and determine coefficients and :

y=x+x

Calculate the Least Squares Error of the model. Make a plot to show the data points (circle marker) vs fitted function (solid line). What is the best estimate of y for x = 1.45 using this function?

-------------------------------------------------------------------------------------------------------------------

clear

clc

x = 0.5:0.1:2;

y = [-17.19, -14.14, -12.51, -10.64, -9.34, -9.00, -7.81, -7.53, -6.49, -5.76, -5.62, -5.26, -4.78, -4.46, -4.41, -4.00];

scatter(x,y)

grid minor

Explanation / Answer

model= lm (y~x)
> summary(model)

Call:
lm(formula = y ~ x)

Residuals:
    Min      1Q Median      3Q     Max
-3.4149 -0.7267 0.3322 1.0120 1.3920

Coefficients:
            Estimate Std. Error t value Pr(>|t|)  
(Intercept) -17.5860     1.0073 -17.46 6.73e-11 ***
x             7.6218     0.7561   10.08 8.45e-08 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.394 on 14 degrees of freedom
Multiple R-squared: 0.8789,    Adjusted R-squared: 0.8703
F-statistic: 101.6 on 1 and 14 DF, p-value: 8.455e-08

y^ = -17.586 + 7.6218 * x

when x = 1.45

y^ = -17.586 + 7.6218 *1.45

= -6.53439