Query 31

#$&*

course 272

12/11 5pm

If your solution to a stated problem does not match the given solution, you should self-critique per instructions at

http://vhcc2.vhcc.edu/dsmith/geninfo/labrynth_created_fall_05/levl1_22/levl2_81/file3_259.htm.

Your solution, attempt at solution: If you are unable to attempt a solution, give a phrase-by-phrase interpretation of the problem along with a statement of what you do or do not understand about it. This response should be given, based on the work you did in completing the assignment, before you look at the given solution.

031. `query

*********************************************

Question: `qQuery problem 7.7.4 points (1,0), (2,0), (3,0), (3,1), (4,1), (4,2), (5,2), (6,2)

Give the equation of the least squares regression line and explain how you obtained the equation.

YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

Your solution:

(1,0) = |(a * 1 + b) - 0|

(2,0) = |(a * 2 + b) - 0|

(3,0) = |(a * 3 + b) - 0|

(3,1) = |(a * 3 + b) - 1|

(4,1) = |(a * 4 + b) - 1|

(4,2) = |(a * 4 + b) - 2|

(5,2) = |(a * 5 + b) - 2|

(6,2) = |(a * 6 + b) - 2|

sum of squared errors:

(|(a * 1 + b) - 0|)^2+( |(a * 2 + b) - 0|) + (|(a * 3 + b) - 0|)^2

(|(a * 3 + b) - 1| )^2+ (|(a * 4 + b) - 1|)^2+ (|(a * 4 + b) - 2|) ^2+

|(a * 6 + b) - 2|)^2 =

116a^2 + 2a(28b-37)+8(b^2)-16b+14

partial derivative with respect to a: 56a+16b-16

partial deriviatve with respect to b: 232a+56b-74

56a+16b-16=0

232a+56b-74=0

using system of equations: a= -1/2 b=-3/4

faa*fbb -4fab^2 = 56 * 56 - 0 = positive number so minimum!

Y = 1/2x - 3/4

confidence rating #$&*: 3

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.............................................

Given Solution:

`a The text gives you equations related to the sum of the x terms, sum of y values, sum of x^2, sum of y^2 etc, into which you can plug the given information.

To use partial derivatives and get the same results. The strategy is to assume that the equation is y = a x + b and write an expression for the sum of the squared errors, then minimize this expression with respect to a and b, which are treated as variables.

If y = a x + b then the errors at the four points are respectively

| (a * 1 + b) - 0 |,

| (a * 2 + b) - 0 |,

| (a * 3 + b) - 0 |,

| (a * 3 + b) - 1 |,

| (a * 4 + b) - 1 |,

| (a * 4 + b) - 2 |,

| (a * 5 + b) - 2 |, and

| (a * 6 + b) - 2 |.

The sum of the squared errors is therefore

sum of squared errors: ( (a * 1 + b) - 0 )^2+( (a * 2 + b) - 0 )^2+( (a * 3 + b) - 0 )^2+( (a * 3 + b) - 1 )^2+( (a * 4 + b) - 1 )^2+( (a * 4 + b) - 2 )^2+( (a * 5 + b) - 2 )^2+( (a * 6 + b) - 2 )^2.

It is straightforward if a little tedious to simplify this expression, but after simplifying all terms, squaring and then collecting like terms we get

116·a^2 + 2·a·(28·b - 37) + 8·b^2 - 16·b + 14.

We minimize this expression by finding the derivatives with respect to a and b:

The derivatives of this expression with respect to a and b are respectively

56·a + 16·b - 16 and 232·a + 56·b - 74.

Setting both derivatives equal to zero we get the system

56·a + 16·b - 16 = 0

232·a + 56·b - 74 = 0.

Solving this system for a and b we get

a = 1/2, b = - 3/4.

So see that this is a minimum we have to evaluate the expression f_aa * f_bb - 4 f_ab^2.

f_aa = 56 and f_bb = 56, while f_ab = 0 so f_aa * f_bb - 4 f_ab^2 is positive, telling us we have a minimum.

Thus our equation is

y = a x + b or

y = 1/2 x - 3/4.

STUDENT QUESTION

I am very clear on this concept, but I am having some issues calculating my sum of the squared errors. Can you provide some clarity here; I am obviously confusing myself. Aside from that point, I am confident with the remaining steps here. 
INSTRUCTOR RESPONSE

Your solution includes

S = (1a + b - 0)^2 + (2a + b - 0)^2 + (3a + b - 0)^2 + (3a + b -1)^2 + (4a + b -1)^2 + (4a + b -2)^2 + (5 a + b - 2)^2 + (6 a + b - 2)^2,
which seems to agree with the data and with my expression
( (a * 1 + b) - 0 )^2+( (a * 2 + b) - 0 )^2+( (a * 3 + b) - 0 )^2+( (a * 3 + b) - 1 )^2+( (a * 4 + b) - 1 )^2+( (a * 4 + b) - 2 )^2+( (a * 5 + b) - 2 )^2+( (a * 6 + b) - 2 )^2
You need to expand your squares. All it takes is the Distributive Law.
(4a + b -1)^2 = (4a + b -1) * (4a + b -1) = 4a * (4a + b -1) + b * (4a + b -1) + (-1) * (4a + b -1). This is a straightforward application of the distributive law.
4a * (4a + b -1) + b * (4a + b -1) + (-1) * (4a + b -1) =(16 a^2 + 4 a b - 4 a) + (4 a b + b^2 - b) + (-4a - b + 1) =16 a^2 + b^2 + 8 a b - 8 a - 2 b - 1.
The other terms can also be squared. You collect all the a^2, b^2, ab, a and b terms, and the pure numbers, and you should get 
116•a^2 + 2•a•(28•b - 37) + 8•b^2 - 16•b + 14.

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

Self-critique (if necessary): ok

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

Self-critique Rating: 3

*********************************************

Question: `qQuery problem 7.7.6 (was 7.7.16) use partial derivatives,etc., to find least-squares line for (-3,0), (-1,1), (1,1), (3,2)

YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

Your solution:

(-3,0) = |(a * -3 + b) - 0|

(-1,1) = |(a * -1 + b) - 1|

(1,1) = |(a * 1 + b) - 1|

(3,2) = |(a * 3 + b) -2|

sum of squared errors:

|(a * -3 + b) - 0|^2 + |(a * -1 + b) - 1|^2 +|(a * 1 + b) - 1|^2 +

|(a * 3 + b) -2|^2 =

20a^2 - 12a +4b^2 - 8b + 6

partial derivative wra = 40a - 12 = 0 when a = .3

partial derivative wrb = 8b - 8 = 0 when b = 1

both values are positive so derivative with respect to a then b = 0 showing critical point gives a minimum

confidence rating #$&*: 3

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.............................................

Given Solution:

`a If y = a x + b then the errors at the four points are respectively

| (a * -3 + b) - 0 |,

| (a * -1 + b) - 1 |,

| (a * 1 + b) - 1 | and

| (a * 3 + b) - 2 |. The sum of the squared errors is therefore

( (a * -3 + b) - 0 )^2 + ( (a * -1 + b) - 1 )^2 + ( (a * 1 + b) - 1 )^2 + ( (a * 3 + b) - 2 )^2 =

[ 9 a^2 - 6 ab + b^2 ] + [ (a^2 - 2 a b + b^2) - 2 ( -a + b) + 1 ] + [ a^2 + 2 ab + b^2 - 2 ( a + b) + 1 ] + [ 9 a^2 + 6 ab + b^2 - 4 ( 3a + b) + 4 ] =

20·a^2 - 12·a + 4·b^2 - 8·b + 6.

This expression is to be minimized with respect to variables a and b.

The derivative with respect to a is 40 a - 12 and the derivative with respect to b is 8 b - 8.

40 a - 12 = 0 if a = 12/40 = .3.

8b - 8 = 0 if b = 1.

The second derivatives with respect to and and b are both positive; the derivative with respect to a then b is zero. So the test for max, min or saddle point yields a max or min, and since both derivatives are positive the critical point gives a min.

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

Self-critique (if necessary): ok

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

Self-critique Rating: 3

*********************************************

Question: What was your expression for the sum of the squared errors?

YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

Your solution:

20a^2 - 12a +4b^2 - 8b + 6

a = .3 b= 1

20(.3)^2 - 12(.3) +4(1)^2 - 8(1) + 6=

.2

confidence rating #$&*: 3

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.............................................

Given Solution:

`a Right, for the values of a and b you correctly obtained above. The expression for squared errors is 20·a^2 - 12·a + 4·b^2 - 8·b + 6.

For a = .3 and b = 1 this expression gives 1.8 - 3.6 + 4 - 8 + 6 = .2.

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

Self-critique (if necessary): ok

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

Self-critique Rating: ok

"

Self-critique (if necessary):

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

Self-critique rating:

"

Self-critique (if necessary):

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

Self-critique rating:

#*&!

&#Good responses. Let me know if you have questions. &#