251progscor 3/25/06
Finding a Sample correlation.
Doing Old Computational Problem 1b on Minitab.
Downing and Clark (formerly pg. 348 now posted at end of 251hwkadd) Old Computational Problem 1: This is obviously sample data, so we compute only a sample covariance and correlation.
b) Compute and .
34 26 9 30 47 10 34 34 45 10 47 32 47 8 45
6 57 89 60 95 42 31 28 90 25 45 23 52 95 48
The program Samcov will compute the sample covariance and correlation for a set of x and y points. The setup is as below. The joint probability is in rows 1-5 of C10-C14. is in C15 and is in C17.
1
251progscor 3/25/06
Column Number / C40 / C41 / C42Column Label / x / y
Row 1 / 34 / 6
Row 2 / 26 / 57
Row 3 / 9 / 89
Row 4 / 30 / 60
Row 5 / 47 / 95
Row 6 / 10 / 42
Row 7 / 34 / 31
Row 8 / 34 / 28
Row 9 / 45 / 90
Row 10 / 10 / 25
Row 11 / 47 / 45
Row 12 / 32 / 23
Row 13 / 47 / 52
Row 14 / 8 / 95
Row 15 / 45 / 48
The space allocation is as follows for computation of the variances.
C1Input is set up by Samcov
C2
K1
K2
K3
K4
K5
K6
K7
K8
The space allocation is as follows for computation of the covariance and correlation.
C40 (Column)
C41(Column)
C42(Column)
C43(Column)
C44(Column)
K40
K41
K42
K43
K44
K45
K46
K47
K48
K49
K50
K51
K52
K53
K54
1
251progscor 3/25/06
Set up a storage area for the program modules, called ‘exec’s by the current version of Minitab.
Load the following modules into the storage area that you have set up for the execs. Each of these is a separate document in ‘txt’ format. Note that # introduces a comment. The first line gives the name of the file.
1
251progscor 3/25/06
#251samcov.txtComputes sample variances
# and covariances using 'var973'
# Input is x column in C40
# y column in C42
name c40 'x'
name c41 'xsq'
name c42 'y'
name c43 'ysq'
name c44 'xy'
name k40 'sumx'
name k41 'sumx2'
name k42 'sumy'
name k43 'sumy2'
name k44 'sumxy'
name k45 'n'
name k46 'xbar'
name k47 'ybar'
name k48 'svarx'
name k49 'svary'
name k50 'scovxy'
name k51 'sx'
name k52 'sy'
name k53 'rxy'
name k54 'rxy2'
let c1=c40
execute 'var973.txt'
let C41=c2
let k40=k1
let k41=k2
let k46=k4
let k48=k5
let k51=k6
let c1=c42
execute 'var973.txt'
let C43=c2
let k42=k1
let k43=k2
let k45=k3
let k47=k4
let k49=k5
let k52=k6
let c44=c40*c42
let k44=sum(c44)
let k50=k45*k46*k47
let k50=k44-k50
let k50=k50/k7
let k53=k51*k52
let k53=k50/k53
let k54=k53*k53
Print c40-c44
Print k40-k54
end
#var973.mtb
#computes sample variance of data in C1.
let k1=sum(c1)
let c2=c1 * c1
let k2=sum(c2)
let k3=count(c1)
let k4=k1/k3 #mean
let k5=k3*k4*k4
let k5=k2-k5
print k5
name k1 'sum'
name k2 'sumsq'
name k3 'count'
name k4 'smean'
name k5 'svar'
name k6 'sdev'
name k7 'DF'
name k8 'sterr'
let k7 = k3 - 1
let k5 = k5/k7
let k6 = sqrt(k5)
let k8 = k5/k3
let k8 = sqrt(k8)
describe c1
print c1-c2
print k1-k8
end
1
251progscor 3/25/06
To use these execs, click on the command area of the screen, open the ‘editor’ pull-down menu and select ‘enable commands.’ Then open the ‘file’ pull-down menu, select ‘other files,’ then ‘run an exec’. Leave the number of times to execute at one and click on ‘select file.’ Locate samcov – you may have to type it in – and hit ‘open.’ This will start the execs running. My results follow with comments. The information given at the beginning of the document was entered by hand before the execs were run. Explanations are indented.
————— 3/25/2006 1:32:15 AM ————————————————————
Welcome to Minitab, press F1 for help.
Executing from file: C:\Documents and Settings\rbove\My Documents\Minitab\251samcov.txt
Executing from file: var973.txt
Data Display
K5 3105.73
Var 973 is called twice by the main program to compute the sample variances. The display above is the variance of x.
Descriptive Statistics: C1
Variable N N* Mean SE Mean StDev Minimum Q1 Median Q3 Maximum
C1 15 0 30.53 3.85 14.89 8.00 10.00 34.00 45.00 47.00
Var 973 uses the command ‘describe C1’ to get statistics on x. The display above is the value of n, the number of blank lines, the mean, or the standard error of the mean, and the 5-number summary.
Data Display
Row C1 C2
1 34 1156
2 26 676
3 9 81
4 30 900
5 47 2209
6 10 100
7 34 1156
8 34 1156
9 45 2025
10 10 100
11 47 2209
12 32 1024
13 47 2209
14 8 64
15 45 2025
The display above consists of the and columns used in the variance computation.
Data Display
sum 458.000
sumsq 17090.0
count 15.0000
smean 30.5333
svar 221.838
sdev 14.8942
DF 14.0000
sterr 3.84567
The display above consists of , , , , , , and .
Executing from file: var973.txt
Data Display
svar 11465.6
The display above is the variance of y.
Descriptive Statistics: C1
Variable N N* Mean SE Mean StDev Minimum Q1 Median Q3 Maximum
C1 15 0 52.40 7.39 28.62 6.00 28.00 48.00 89.00 95.00
Var 973 uses the command ‘describe C1’ to get statistics on y. The display above is the value of n, the number of blank lines, the mean, or the standard error of the mean, and the 5-number summary.
Data Display
Row C1 C2
1 6 36
2 57 3249
3 89 7921
4 60 3600
5 95 9025
6 42 1764
7 31 961
8 28 784
9 90 8100
10 25 625
11 45 2025
12 23 529
13 52 2704
14 95 9025
15 48 2304
The display above consists of the and columns used in the variance computation.
Data Display
sum 786.000
sumsq 52652.0
count 15.0000
smean 52.4000
svar 818.971
sdev 28.6177
DF 14.0000
sterr 7.38905
The display above consists of , , , , , , and .
Data Display
Row x xsq y ysq xy
1 34 1156 6 36 204
2 26 676 57 3249 1482
3 9 81 89 7921 801
4 30 900 60 3600 1800
5 47 2209 95 9025 4465
6 10 100 42 1764 420
7 34 1156 31 961 1054
8 34 1156 28 784 952
9 45 2025 90 8100 4050
10 10 100 25 625 250
11 47 2209 45 2025 2115
12 32 1024 23 529 736
13 47 2209 52 2704 2444
14 8 64 95 9025 760
15 45 2025 48 2304 2160
The display above consists of the , , , and columns.
Data Display
sumx 458.000
sumx2 17090.0
sumy 786.000
sumy2 52652.0
sumxy 23693.0
n 15.0000
xbar 30.5333
ybar 52.4000
svarx 221.838
svary 818.971
scovxy -21.8714
sx 14.8942
sy 28.6177
rxy -0.0513127
rxy2 0.00263299
The final display above consists of , , , , , , , , , , , , , and . We now have all the information we need to fake the following computation.
,,, and .
and .
1