252prog5/6/99

You may need ‘c:\minitab\progname’ to execute from c drive.

To set up any of these programs try

Store ‘a:progname’

At the beginning. (Replace progname with the name of the program.)Type in the program. It will go on your disk if you use a:, into the pc if you do not use a:.

To run the program try

Execute ‘a:progname’

Programs to Create F Table

#ftableg.mtbGenerates F table.

let k8=24#k8 is number of numerator values in c4.
let k9=52#k9 is number of denominator values in c3.
execute 'finit'
execute 'frow' k9
end

#frow.mtbGenerates row of F table.

Let k3=1
execute 'frowitem' k8
let k4=k4+1
end

#fcomp.mtbComputes critical values of F distribution.

let k1=c4(k3)#c1 contains 3 confidence levels.

let k2=c3(k4)#c2 contains results.

invcdf c1 c2;

f k1 k2.#k1 is degrees of freedom for numerator.

end#k2 is degrees of freedom for denominator.

#frowitem.mtbComputes Critical Values for 1 row item of F table

Execute 'fcomp'

Print k1 k2

Print c2#k3 is index in c4.

let k6=k4-1#k4 is index in c3.

let k5=k3+9#ck5 is the column to be used, starting with c10.

let k7=k6*4#c4 contains numerator degrees of freedom.

let k7=k7+1#c3 contains denominator degrees of freedom.

let ck5(k7)=c2(1)#k7 is index in ck5.

let c9(k7)=1-c1(1)#c9 contains significance levels.

let k7=k7+1

let ck5(k7)=c2(2)

let c9(k7)=1-c1(2)

let k7=k7+1

let ck5(k7)=c2(3)

let c9(k7)=1-c1(3)

let k3=k3+1

end

252prog5/6/99

#finit.mtbInitializes F table

let k1=1

let k2=1

let k3=1

let k4=1

let k5=1

end

#252-2m1Computes std deviations and runs 2mean.

name k201 's1 sq'

name k202 'n 1'

name k203 's2 sq'

name k204 'n 2'

name k205 's1'

name k206 's2'

let k205= stdev(c1)#Data is in C1 and C@

let k206= stdev(c2)

let k201=k205*k205

let k202= count(c1)

let k203= k206*k206

let k204= count(c2)

print k205,k206

execute '2mean'

end

#2meanComputes material for hypothesis test of 2 means

#set k1=s1square, k2=n1, k3=s2squared, k4=n2
let k205=k201/k202#s1sq/n1
let k206=k203/k204#s2sq/n2
name k207 'sdbrsq'
let k207=k205+k206#sdbar squared – unequal variances

name k208 'sdbar'

let k208=sqrt(k207)#sdbar

let k209=k207*k207#numerator for df
let k210=k202-1
let k211=k204-1
let k214=k210*k201
let k215=k211*k203
let k217=k214+k215
let k216=k210+k211#sp squared
let k216=k217/k216

let k217=1/k202

let k218=1/k204

let k219=k217+k218

let k220=k216*k219

name k221 'sdbr1'

let k221 =sqrt(k220)#sdbar – equal variances

let k210=k205*k205/k210

let k211=k206*k206/k211#denominator for df

let k212=k210+k211

name k213 'df'

let k213=k209/k212#df

print k201-k221

end
252prog5/6/99

252chisqOld Version. Computes chi-square columns

let c12=c10-c11O on c10, E in C11

let k12=sum(c12)Should be zero

let k10=sum(c10)k10=k11=n

let k11=sum(c11)

let c13=c12*c12

let c13=c13/c11Sums to Chi-squared

let k13=sum(c13)

let c14=c10*c10Shortcut method

let c14=c14/c11

let k14=sum(c14)

let k15=k14-k10Chi-squared again

print c1-c14

print k10-k15

end

#252chisqNew Version. Computes chi-square column

Name c1 'O'#O on c1, E in C2
Name c2 'E'
let c3='E'-'O'
let c4=c3*c3

let c5=c4/'E'

let c6='O'*'O'#Shortcut method

let c6=c6/'E'

print c1-c6

name k1 'n'

let k1=sum(c1)#k1=k2=n

let k2=sum(c2)

let k3=sum(c3)#Should be zero

let k5=sum(c5)

name k5 'chisq'

let k6=sum(c6)

name k4 'chisq1'

let k4=k6-k1

print k1-k6

end

252prog5/6/99

#252solsFakes simple ols regression by hand

regress c1 on 1 c2
let c3=c2*c2#Put y in c1, x in c2
let c4=c1*c2#c3 is x squared, c4 is xy
let c5=c1*c1#c5 is y squared

let k1=sum(c1)#k1 is sum of y

let k2=sum(c2)#k2 is sum of x

let k3=sum(c3)#k3 is sum of x squared

let k4=sum(c4)#k4 is sum of xy

let k5=sum(c5)#k5 is sum of y squared

print c1-c5

let k17=count(c1)#k17 is n

let k21=k2/k17#k21 is mean of x

let k22=k1/k17#k22 is mean of y

let k18=k21*k21*k17

let k18=k3-k18#k18 is SSx

let k19=k22*k22*k17

let k19=k5-k19#k19 is SSy

let k20=k21*k22*k17

let k20=k4-k20#k20 is SSxy

print k1-k5

print k17-k22

end

#252-2wayDoes 2-way ANOVA

table c2,c3#Data in C1, Row in C2, Column in C3.

table c2,c3;

data c1.

table c2,c3;

mean c1.

twoway c1, c2, c3

end

#252sols3Does third computer problem

print c1 c2#y in c1, x in c2, resid in c3, pred in c4.

plot c1*c2

regress c1 on 1 c2 c3 c4

plot c4*c2

plot c4*c2 c1*c2;

symbol;

type 3 1;

color 8 9;

overlay.

end

252prog5/6/99

#2IVolsDoes spare parts for a regression problem with 2 independent #variables. Put y in C1, x1 in C2, x2 in c3.

execute '2IVnamer'#Names Columns and Constants.

execute '2IVsumer'#Sums Columns.

print c1-c5

print c6-c10

print k1-k10

execute '2IVmean'#Computes means.

print k11-k13

execute '2IVss'#Computes spare parts.

print k15-k20

end

#2IvnamerNames columns and constants

name c5 'x1sq'
name c6 'x2sq'

name c7 'ysq'

name c8 'x1y'

name c9 'x2y'

name c10 'x1x2'

name k1 'sumy'

name k2 'sumx1'

name k3 'sumx2'

name k4 'n'

name k5 'smx1sq'

name k6 'smx2sq'

name k7 'smysq'

name k8 'smx1y'

name k9 'smx2y'

name k10 'smx1x2'

name k11 'ybar'

name k12 'x1bar'

name k13 'x2bar'

name k15 'SSx1'

name k16 'SSx2'

name k17 'SSy'

name k18 'Sx1y'

name k19 'Sx2y'

name k20 'Sx1x2'

end

252prog5/6/99

#2IvsumerFills columns and sums them

let k1=sum(c1)#Sum of y
let k2=sum(c2)#Sum of x1
let k3=sum(c3)#Sum of x2

let k4=count(c1)#n

let c5=c2*c2

let k5= sum(c5)#Sum of x1 squared

let c6=c3*c3

let k6=sum(c6)#Sum of x2 squared

let c7=c1*c1

let k7= sum(c7)#Sum of y squared

let c8=c2*c1

let k8=sum(c8)#Sum of x1*y

let c9=c3*c1

let k9=sum(c9)#Sum of x2*y

let c10=c2*c3

let k10=sum(c10)#Sum of x1*x2

end

#2IvmeanComputes means

let k11=k1/k4#Mean of y
let k12=k2/k4#Mean of x1
let k13=k3/k4#Mean of x2
end

#2IvssComputes spare parts

let k15=k4*k12*k12
let k15=k5-k15#SSx1
let k16=k4*k13*k13

let k16=k6-k16#SSx2

let k17=k4*k11*k11

let k17=k7-k17#SSy

let k18=k4*k12*k11

let k18=k8-k18#Sx1y

let k19=k4*k13*k11

let k19=k9-k19#Sx2y

let k20=k4*k12*k13

let k20=k10-k20#Sx1x2

end

252prog 5/6/99

#252corrComputes correlation between items in c1 c2 and c3

Let k1=sum(c1)
name k1='sumx1'
Let k2=sum(c2)
name k2='sumx2'

Let k3=sum(c3)

name k3='sumx3'

let c7=c1*c1

name k7 = 'ssx1'

let k7 = sum(c7)

let c8=c2*c2

name k8 = 'ssx2'

let k8 = sum(c8)

let c9=c3*c3

name k9 = 'ssx3'

let k9 = sum(c9)

let c10=c1*c2

name k10 = 'sx12'

let k10 = sum(c10)

let c11=c1*c3

name k11 = 'sx13'

let k11 = sum(c11)

let c12=c2*c3

name k12 = 'sx23'

let k12 = sum(c12)

print c1-c3

print k1-k3

print c7-c12

print k7-k12

corr c1 c2

corr c1 c3

corr c2 c3

end

252prog 5/6/99

#252crr1Follows 252corr. Input in c1, c2 - ssx1 in k7, ssx2 in k8 etc

name k20 'ssx1c'

name k21 'x1bar'

name k22 'ssx2c'

name k23 'x2bar'

name k24 'n1'

name k25 'r12'

name k26 'sx12c'

name k27 'Rsq12'

let k24=count(c1)

let k21=k1/k24

let k23=k2/k24

let k20=k24*k21*k21

let k20=k7-k20

let k22=k24*k23*k23

let k22=k8-k22

let k26=k24*k23*k21#Gets spare parts for correlation

let k26=k10-k26

let k27=k26*k26

let k27=k27/k20

let k27=k27/k22

let k28=k26/Absolute(k26)

let k25=sqrt(k27)

let k25=k28*k25

print k24, k21, k23

print k20, k22, k26

print k27, k25

end

#252crnzComputes t for t-test of correlation when rho is not zero

name k100='r'#sample correlation in k100
name k101='rho'#population correlation in k101
name k105='t'#output in k105
name k103='n'#n in k103
let k106=k100
execute '252crnz1'
let k105=k107
let k106=k101
execute '252crnz1'
let k104=k103-3

let k104=1-k104

let k104=sqrt(k104)

let k105=k105-k107

let k105=k105/2

let k105=k105/k104

print k100, k101, k103, k105

end

#252crnz1Subroutine to compute parts of numerator in t.

let k108=1-k106#Input in k106
let k107=1+k106#Output in k107
let k107=k107/k108
let k107=loge(k107)
let k107=k107/2

end

252prog 5/6/99

#252crzComputes t for correlation when rho is zero

name k100='r'
name k101='rho'
name k105='t'
name k103='n'
let k105=k100*k100

let k106=1-k105

let k105=k105/k106

let k106=k103-2

let k105=k105*k106

let k105=sqrt(k105)

print k100, k101, k103, k105

end

#252onewComputes sums for one way ANOVA with 3 columns

AOVOneway c1 c2 c3#Data is in C1 C2 C3
execute '252onmer'
execute '252osmer' #Puts squares in C5, C6 and C7.

print c1-c3

print c5-c7

print k1-k4,k8-k9,k5-k7

execute '252omean'

print k11-k13

end

#252onmerSubroutine. Names quantities.

name c5 'x1sq'
name c6 'x2sq'
name c7 'x3sq'
name k1 'sumx1'
name k2 'sumx2'
name k3 'sumx3'
name k4 'n1'
name k8 'n2'
name k9 'n3'
name k5 'smx1sq'
name k6 'smx2sq'
name k7 'smx3sq'
name k11 'x1bar'
name k12 'x2bar'
name k13 'x3bar'

end

252prog 6/21/99

#252osmerSubroutine. Computes sums and sums of squares for C1, C2, and C3

let k1=sum(c1)

let k2=sum(c2)

let k3=sum(c3)

let k4=count(c1)

let k8=count(c2)

let k9=count(c3)

let c5=c1*c1

let k5= sum(c5)

let c6=c2*c2

let k6=sum(c6)

let c7=c3*c3

let k7= sum(c7)

end

#252omeanSubroutine. Computes column means.

let k11=k1/k4

let k12=k2/k8

let k13=k3/k9

end

#252rkTakes C1-C3, ranks within columns and computes rank correlations.

rank c1 c4

rank c2 c5

rank c3 c6

corr c4 c5

corr c4 c6

corr c5 c6

print c1 c4 c2 c5 c3 c6

end

#252revcReverses indexes in column indicated in k100

name k101 = 'n'

name k100 = 'col'

let k101 = count(ck100)

print ck100

print k100-k101

name k102 = 'i'

let 'i'= 0

execute '252rvc1' k101

print ck100

end

#252rvc1Subroutine. Part of stuff to reverse ranking in one column.

let 'i' = 'i' + 1#Column number is in k100

let ck100('i') = 'n'- ck100('i') + 1

end

252prog 6/21/99

#tcompmakes t table.

let k1=1#C1 is significance levels

let k2=1#c2 is t values for latest value of df

let k4=1#c3 is df

let k3=count(c3)

execute 'tcomp1' k3

echo

write 'c:\files\winword\1scratch.doc' c3 c10-c22;

format (f3.0,1x,13(f5.3,1x));

replace.#Above is the name of file to export data to, followed

end#by format 5 spaces with 3 to right of decimal.

#tcomp1Does one line of t-table

let k1=c3(k2)
invcdf c1 c2;
T k1.
let k5=1
execute 'trow' 13
let k2=k2+1
end
#trowDoes one element of t-table

let k4=9+k5
let ck4(k2)=c2(k5)

let k5=k5+1

end

1