The mean and standard deviation of Yare computed with the same formulas. These quantities are then used to calculate the
correlation coefficient between the two variables using the formulas:
S
f P
S
f X
*
Y
(Sum of X)
*
(Sum of Y)
um
0
roductsx,y =
um
0
-
N
Correlation x,y
Sum of Products(x,y)
.J
(Sum of Squares x )
*
(Sum of Squares y )
Finally the program computes the coefficients for the linear regression equation using the formulas:
Sum of Productsx,y
Sum of Squares y
a = Meany - (b x . y
*
Mean x )
The coefficients are then shown in the regression equation:
Y=a+bx.yX
Relationship of Two Variables Program
10: A
=
0, B
=
0, C
=
0, 0
=
0,
v =
0
20:
INPUT "NUMBER OF OBSERV.? "; N
30:
DIM
X(NI, Y(N)
40:WAIT48
50:
PAUSE "ENTER "; N;" PAIRS OF OBS:'
Initialize variables to accumulate sums
Get number of observations
Allocate arrays to hold observations
Set 3/4 second wait for prompts during data entry
Prompt start of data entry
199