# 9.1 Least squares, calculator work, correlation coefficients

 Page 1 / 2

## The method of least squares

We now come to a more accurate method of finding the line of best-fit. The method is very simple. Suppose we guess a line of best-fit. Then at at every data point, we find the distance between the data point and the line. If the line fitted the data perfectly, this distance should be zero for all the data points. The worse the fit, the larger the differences. We then square each of these distances, and add them all together.

The best-fit line is then the line that minimises the sum of the squared distances.

Suppose we have a data set of $n$ points $\left\{\left({x}_{1};{y}_{1}\right),\left({x}_{2};{y}_{2}\right),...,\left({x}_{n},{y}_{n}\right)\right\}$ . We also have a line $f\left(x\right)=mx+c$ that we are trying to fit to the data. The distance between the first data point and the line, for example, is

$\text{distance}={y}_{1}-f\left(x\right)={y}_{1}-\left(mx+c\right)$

We now square each of these distances and add them together. Lets call this sum $S\left(m,c\right)$ . Then we have that

$\begin{array}{ccc}\hfill S\left(m,c\right)& =& {\left({y}_{1}-f\left({x}_{1}\right)\right)}^{2}+{\left({y}_{2}-f\left({x}_{2}\right)\right)}^{2}+...+{\left({y}_{n}-f\left({x}_{n}\right)\right)}^{2}\hfill \\ & =& \sum _{i=1}^{n}{\left({y}_{i}-f\left({x}_{i}\right)\right)}^{2}\hfill \end{array}$

Thus our problem is to find the value of $m$ and $c$ such that $S\left(m,c\right)$ is minimised. Let us call these minimising values ${m}_{0}$ and ${c}_{0}$ . Then the line of best-fit is $f\left(x\right)={m}_{0}x+{c}_{0}$ . We can find ${m}_{0}$ and ${c}_{0}$ using calculus, but it is tricky, and we will just give you the result, which is that

$\begin{array}{ccc}\hfill {m}_{0}& =& \frac{n{\sum }_{i=1}^{n}{x}_{i}{y}_{i}-{\sum }_{i=1}^{n}{x}_{i}{\sum }_{i=1}^{n}{y}_{i}}{n{\sum }_{i=1}^{n}{\left({x}_{i}\right)}^{2}-{\left({\sum }_{i=1}^{n},{x}_{i}\right)}^{2}}\hfill \\ \hfill {c}_{0}& =& \frac{1}{n}\sum _{i=1}^{n}{y}_{i}-\frac{{m}_{0}}{n}\sum _{i=0}^{n}{x}_{i}=\overline{y}-{m}_{0}\overline{x}\hfill \end{array}$

In the table below, we have the records of the maintenance costs in Rands, compared with the age of the appliance in months. We have data for 5 appliances.

 appliance 1 2 3 4 5 age ( $x$ ) 5 10 15 20 30 cost ( $y$ ) 90 140 250 300 380

Find the line of best fit using the method of least squares.

1.  appliance $x$ $y$ $xy$ ${x}^{2}$ 1 5 90 450 25 2 10 140 1400 100 3 15 250 3750 225 4 20 300 6000 400 5 30 380 11400 900 Total 80 1160 23000 1650
2. $\begin{array}{ccc}\hfill {m}_{0}& =& \frac{n\sum xy-\sum x\sum y}{n\sum {x}^{2}-{\left(\sum ,x\right)}^{2}}=\frac{5×23000-80×1160}{5×1650-{80}^{2}}=12\hfill \\ \hfill {c}_{0}& =& \overline{y}-b\overline{x}=\frac{1160}{5}-\frac{12×80}{5}=40\hfill \\ & \therefore & \underline{\stackrel{^}{y}=40+12x}\hfill \end{array}$

## Using a calculator

Find a regression equation for the following data:

 Days ( $x$ ) 1 2 3 4 5 Growth in m ( $y$ ) 1,00 2,50 2,75 3,00 3,50
1. Using your calculator, change the mode from normal to “Stat $xy$ ”. This mode enables you to type in bivariate data.

2. Key in the data as follows:

 1 $\left(x,y\right)$ 1 DATA $n$ = 1 2 $\left(x,y\right)$ 2,5 DATA $n$ = 2 3 $\left(x,y\right)$ 2,75 DATA $n$ = 3 4 $\left(x,y\right)$ 3,0 DATA $n$ = 4 5 $\left(x,y\right)$ 3,5 DATA $n$ = 5
3. Ask for the values of the regression coefficients $a$ and $b$ .

 RCL $a$ gives $a=$ 0,9 RCL $b$ gives $b=$ 0,55
$\therefore \stackrel{^}{y}=0,9+0,55x$

Using a calculator determine the least squares line of best fit for the following data set of marks.

 Learner 1 2 3 4 5 Chemistry (%) 52 55 86 71 45 Accounting (%) 48 64 95 79 50

For a Chemistry mark of 65%, what mark does the least squares line predict for Accounting?

1. Switch on the calculator. Press [MODE] and then select STAT by pressing [2]. The following screen will appear:

 1 1-VAR 2 A + BX 3 $_$ + CX ${}^{2}$ 4 ln X 5 e $\stackrel{^}{}$ X 6 A . B $\stackrel{^}{}$ X 7 A . X $\stackrel{^}{}$ B 8 1/X

Now press [2] for linear regression. Your screen should look something like this:

 x y 1 2 3
2. Press [52] and then [=]to enter the first mark under $x$ . Then enter the other values, in the same way, for the $x$ -variable (the Chemistry marks) in the order in which they are given in the data set. Then move the cursor across and up and enter 48 under $y$ opposite 52 in the $x$ -column. Continue to enter the other $y$ -values (the Accounting marks) in order so that they pair off correctly with the corresponding $x$ -values.

 x y 1 52 2 55 3

Then press [AC]. The screen clears but the data remains stored.

 1: Type 2: Data 3: Edit 4: Sum 5: Var 6: MinMax 7: Reg

Now press [SHIFT][1]to get the stats computations screen shown below. Choose Regression by pressing [7].

 1: A 2: B 3: r 4: $\stackrel{^}{x}$ 5: $\stackrel{^}{y}$
1. Press [1] and [=]to get the value of the $y$ -intercept, $a=-5,065..=-5,07$ (to 2 d.p.) Finally, to get the slope, use the following key sequence: [SHIFT][1][7][2][=]. The calculator gives $b=1,169..=1,17$ (to 2 d.p.) The equation of the line of regression is thus: $\stackrel{^}{y}=-5,07+1,17x$
2. Press [AC][65][SHIFT][1][7][5][=] This gives a (predicted) Accounting mark of $\stackrel{^}{}=70,94=71$ %

can someone help me with some logarithmic and exponential equations.
20/(×-6^2)
Salomon
okay, so you have 6 raised to the power of 2. what is that part of your answer
I don't understand what the A with approx sign and the boxed x mean
it think it's written 20/(X-6)^2 so it's 20 divided by X-6 squared
Salomon
I'm not sure why it wrote it the other way
Salomon
I got X =-6
Salomon
ok. so take the square root of both sides, now you have plus or minus the square root of 20= x-6
oops. ignore that.
so you not have an equal sign anywhere in the original equation?
Commplementary angles
hello
Sherica
im all ears I need to learn
Sherica
right! what he said ⤴⤴⤴
Tamia
what is a good calculator for all algebra; would a Casio fx 260 work with all algebra equations? please name the cheapest, thanks.
a perfect square v²+2v+_
kkk nice
algebra 2 Inequalities:If equation 2 = 0 it is an open set?
or infinite solutions?
Kim
The answer is neither. The function, 2 = 0 cannot exist. Hence, the function is undefined.
Al
y=10×
if |A| not equal to 0 and order of A is n prove that adj (adj A = |A|
rolling four fair dice and getting an even number an all four dice
Kristine 2*2*2=8
Differences Between Laspeyres and Paasche Indices
No. 7x -4y is simplified from 4x + (3y + 3x) -7y
is it 3×y ?
J, combine like terms 7x-4y
im not good at math so would this help me
yes
Asali
I'm not good at math so would you help me
Samantha
what is the problem that i will help you to self with?
Asali
how do you translate this in Algebraic Expressions
Need to simplify the expresin. 3/7 (x+y)-1/7 (x-1)=
. After 3 months on a diet, Lisa had lost 12% of her original weight. She lost 21 pounds. What was Lisa's original weight?
what's the easiest and fastest way to the synthesize AgNP?
China
Cied
types of nano material
I start with an easy one. carbon nanotubes woven into a long filament like a string
Porter
many many of nanotubes
Porter
what is the k.e before it land
Yasmin
what is the function of carbon nanotubes?
Cesar
what is nanomaterials​ and their applications of sensors.
what is nano technology
what is system testing?
preparation of nanomaterial
Yes, Nanotechnology has a very fast field of applications and their is always something new to do with it...
what is system testing
what is the application of nanotechnology?
Stotaw
In this morden time nanotechnology used in many field . 1-Electronics-manufacturad IC ,RAM,MRAM,solar panel etc 2-Helth and Medical-Nanomedicine,Drug Dilivery for cancer treatment etc 3- Atomobile -MEMS, Coating on car etc. and may other field for details you can check at Google
Azam
anybody can imagine what will be happen after 100 years from now in nano tech world
Prasenjit
after 100 year this will be not nanotechnology maybe this technology name will be change . maybe aftet 100 year . we work on electron lable practically about its properties and behaviour by the different instruments
Azam
name doesn't matter , whatever it will be change... I'm taking about effect on circumstances of the microscopic world
Prasenjit
how hard could it be to apply nanotechnology against viral infections such HIV or Ebola?
Damian
silver nanoparticles could handle the job?
Damian
not now but maybe in future only AgNP maybe any other nanomaterials
Azam
can nanotechnology change the direction of the face of the world
At high concentrations (>0.01 M), the relation between absorptivity coefficient and absorbance is no longer linear. This is due to the electrostatic interactions between the quantum dots in close proximity. If the concentration of the solution is high, another effect that is seen is the scattering of light from the large number of quantum dots. This assumption only works at low concentrations of the analyte. Presence of stray light.
the Beer law works very well for dilute solutions but fails for very high concentrations. why?
how did you get the value of 2000N.What calculations are needed to arrive at it
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!