hp calculators
HP 30S Statistics – Linear Regression
Linear regression
A regression of y on x is a way of predicting values of y when values of x are given. If the regression is based on a
straight line graph, it is called a linear regression, and the straight line is called the regression line.
The regression line (sometimes referred to as the line of best fit) of y on x is then the line that gives the best prediction of
values of y from those of x, and is:
where
n
x
b
y
a
i
i
∑
∑
−
=
and
n
)
x
(
x
n
y
x
y
x
b
i
i
i
i
i
i
2
2
∑
∑
∑
∑
∑
−
−
=
bx
a
y
+
=
n being the number of data pairs. (Note that the regression line of x on y, which is usually different from the regression
line of y on x, can be found by interchanging x and y in the above expressions). a and b are known as the linear
regression coefficients. The independent variable is the regressor, and the dependent variables is called regressand.
The coefficients are found by minimizing the sum of the squares of the vertical distances of the points from the line (i.e.
the sum of the squares of the residuals). This method is known as least squares.
The correlation coefficient is a measure of the amount of agreement between the x and y variables, and is given by:
⎟
⎟
⎠
⎞
⎜
⎜
⎝
⎛
−
⎟
⎟
⎠
⎞
⎜
⎜
⎝
⎛
−
−
=
∑
∑
∑
∑
∑
∑
∑
n
)
y
(
y
n
)
x
(
x
n
y
x
y
x
r
i
i
i
i
i
i
i
i
2
2
2
2
When r is positive, the correlation is positive, which means that high values of one variable correspond to high values of
the other. Conversely, if r is negative then the correlation is negative: low values of one variable correspond to high
values of the other. An important property of r is that
1
1
≤
≤
−
r
. The
±
1 values correspond to a perfect correlation:
real values and estimates are exactly the same. If r = 0 then there’s no correlation: x and y are uncorrelated.
On the HP 30S, linear regressions are calculated in 2-VAR STAT operating mode. First of all, let’s clear any previous
data. To do so, press
–1
to display the STAT menu, and then select CLR-DATA using the
<
and
@
keys, finally
press
y
to confirm. Next, press
–1
again, select 2-VAR, and press
y
. You’re now ready to carry out
regression calculations on your calculator, which are illustrated by the following examples.
Practice solving linear regression problems
Example 1: A quality control engineer notes a relationship between the amount of chemical added to a batch, and the
final concentration of the chemical in the final product. The following table shows the weight in grams
added (x) and the weight in the final product (y):
hp calculators
- 2 -
HP 30S Statistics – Linear Regression - Version 1.0