RESEARCH REPORT
$UR'fiI 76 EOITI}R,
å
hIEH TOOLFSR II{TERACTIIE STATISTICAL COITPUTII{G, TEXT AI{O SATå I{åI{åGEI{E}IT
by Seppo l'lustonen
No. 19 August 1990
DEPARTMENT OF STATISTICS
UNIVERSITY OF HELSINKI
SF
OOl OOHELSINKI
1OFINLAND
3.
4.
CII}TTEilTS
1.
Introductionfl,
Anintroductory
exånple5,
Use o+
edit
keys Textediting
4,1.
Clearingthe edit field
4,ä,
l{Evingparts of the edit field
4 "
3,
Savi.ns, loading and conbiningedit fie
tds4,4, Printsut of the edit field
andedit files {"5,
lteking up andadjueting the text
lineE4,5,
Searchingfor strings
Editing
operationsfor
datanatrices
5,
l.
Fornatting5,e,
Sorting5,3,
l{unericaI
sperations5.d,
Loeding and såvins $URt0 ?6files
l{u
ltirey
täb les6.1.
Definition of a
nultiuay
tab le6,e"
Table
aånegetsent andediting 6,3.
Anelyeisrf
variance6,4, Log-linear
nodelsfor
contingency tabIEsCarrelatians
and rBgression ånalysisREFEffENCES
13 15
$
1?
18 19 a0 e1 aa e3 e3 g5 31
&4
w ffi
39
{3
46 50 6.
7.
$, r'lu såBn en
:
SURVil ?6 t0 I Til ft å$.8,19SSStlStE"Fffi lt6 Ht) I fn $t, ä
rreur tcrcr
3,Scrr -i-nter*åctive steit is*-ica
3"t-ex t* artel dat*a TnåfiåclBnrerrt c clrnp u t irr
Slr
by Seppo l{ustonen
Oepantnent
of Statistics University o{ Helsinki
1. Introduction
SURI/0 ?6
is
aninteractive statistical
systeu intendedto
cöver acide
rangeof activities in colputational statistics, It,
has beendesigned
especially {or the
needso{ statisticianE in
both teaching and reEearch nork andits ains are slightly di{{erent frou
thoseof
conventionalstatistical
packages generallyavailable for
data analy-sis, In a certain
sensethe
scopeof
SURt(t ?6is rider pernitting
ex-tended
possibilities for
data andteri
ranagelent,sirulation, natiix
conputetions and
graphical
analyeisin interaciive
node (see l{ustonen 1977,1980),In the
pnesent Sorn SURtdl ?6 has been inpleoented onthe
desk corpu-ter
lhng ?AOOIJPnhich
providessuitable
neans{or rapid
interchangeof in{ornation
befueenthe
systen andthe
user.SURW ?5
is
aninteractive systel
and nospecial job
describirrg lan- guageor
codeis
needed. Usingthis
systenis like
discuEsingrith
the conPuter; we sPeak ahout SURtdl ?6 conversEtiong. The discussionis transuitied frou the syster to the
user bya
CRTdisplay
(speedis alnost
5000 characiers/sec.)
andfron the
userto the syster
vi.a a keyboard havingalso H
progrannablesoft
keys{or control tasks.
Forå
nore preciEe anddetailed outpui a line printer, a
graphic CRT and aplotier are available.
SURlnl 76
consists at the nment o{
about 60stålistical
suhsysters and prograns andthe total
voluneis ahoEt I nillion
byteso{
progpåmtext,, Foruatly the rhole
syEtenis a single
proglsnnritten in
the exiended BASIC lansuageo{
}lang.In thiE
påperre shåll
describea ns
subysten $URUI ?6 EOITOR chichis
intendedfor
varioustext
and dataediting activities in
connectionnith ståtiEtical
data analysis.It, is quite
coilnonthat
rhenuriiing a
researchreport
containing nrtnericaltables the
outputfron the
conputer cannot he usedås
such,but the reEults
haveto
be retypednanually.
Thislay
happen eveni{
the
conputeroutput is nell
designed, sincethe
needso{ the
user u€y change duringthe reporting
phase.In
aninteractive
environnent a goodray o{
avoiding tho'Eeeditorial
problemgis ts
havetert
process-ing {åcilitips in
connectisnnith the statistical
systen.The
nain
purposeof
EDIT0Ris io
lessenthe
burdeno{ a statistician
in
date nanagenent andreport urifing.
Thiseditor
can be used notonly for
ståndardtext
processing purposes,but also {or various
tasks encounteredin statistical daia
processinglike
l) input
åndediting
un{ormatted data,ä
)
såvins datain
SURU0 76 f r leE,3
) editing
SURI'U ?6fi les
ånd re'ults,
4
)
Egrting ånd tranEforrrins datao5
)
nånipulatins lists
and nrultiuay
täb les,6)
data ånälyEis uEing techniquesprs+itåble in editine
node.S"musto$s$; SURW ?6 äilITfifr L0" 8" 19SS
For instance,
problensin analysis o{
variance andlog-linear
nodelsfor
contingencytables
can beeasily
handledin
$URIJ0 ?6 EDIT0R,The uhole
editing
processis controlled with the
normal keyboard keys andprogramnable'soft keys'
(F-keys) nhichare
used{or
sinpletext editing,
For nore conplicatediasks
severalediting
oPerationsare available.
All the in{onnation is
representedin an 'edit {iel.d'
nhich con-sists, {or
exanPlE,o{
100 colunns and å50rols.
The{ield is
alnayspartially visible
onthe
CRT, Theediting
operationsare also
tvpedin
this {ietd
andthey
can betreated as
nornaltext.
Any oPeration canbe
activated
bymving the
cursorto the
corresPondingline
and by pressins key C0t{TIl{tE. Thenever needEdthe
contentssf the edit field (tables, text
and operations) can be såvedin
anedit file.
The
edit {ield is like a
noiebook{or the user, but it is ilch
nore{lexible, since text
and datain that
noteboo}r can beinterpreted
bvediting
opårations andthe results o{
these oPerations can be directedto
anypart o{ ihe {ield.
Sincethe editing
oPerations thenselves are typed anongthe text
and datathe
user can place thEnas
helikes, usually
nearthe object of
operation,If
i,heuser likes
he canput the
oPerations on edjacEntlines
andcarry oul
then ctep by step as aneditiRg
Prograu,but
uEuallythis is
unneces$try. 0n
the conttany, it is typical ihat
duringthe editing
processthe edit field is {itled
bya nixture o{ text'
data and oPeP-ations,
andthe
user scralches unessentialinsredients
nhen needed-In the nert
chapters uetry to illustrate nith
sonepractical
exauples
of hw io
use EOIT0R{or typical
data andtert
Processingactivities. In
rhaFter?
uegive
anintroductory
etanplerelated ts analysis o{
contingencytableE. Also the
fundanentalso{
ståndardtext editing are brie{ly
describedin this
connection. ChaptEr3
introducesthe
taEkso{ editing
keys and chapters4,5 the editing
oPerations{or norlal text
and data ranagenent.In
chapters5
and?
soueståtistical
operetions
are to
be described.$.f4{lst,CIneil: $URW ?6 [SIT{}R, å0" s,1ås0
?"
An iJrtnoductory exanp-leShen SURtt! ?6
is in
use EOITORnilt
becalled
by naneE like
other SURlitl ?6 rrodules.At {irst a list of
possibleF-starts is
displaved onthe
screen.Disp.?.1
SURI{I ?6 EDITOR (C)19?9 S.I{USTONEN, Iff'IITJERSITY CIF HEI-SIilKI
Fl:
BASIC STARTF5:
SAIJE TEI,IPORARY FILEF6:
LOAD TE}IPORARY FILEF8:
LOAO 'II,IDEX' FILE FROI{ THE OATA DISHEOIT FIELD: 100 R0IS, 100
COLrS{ilS
(ilAX eGAx
100)Then
starting nith a
neniob usually the
basicstart Fl ritl
beewloyed
ai firEt
and then thE upperleft side correr of
an eupt'vedit {isld is
displayed onthe
84x80 screen:0,*EP*åf.
I
RUI} 76 EO ITOR tc )19?9 S,H1*_ e*
3* 4*
5* å*
7* s*
10* 9*
lt* $*
13* 14*
t5* 16*
1?* 18*
e0* 1g*
g1
*ae* e3*
The cursor
is bl,inkins in the first position of the edit field
andthe
uEer canEtart typins text,
data values andEditing
oPerations accordingto his
needs'Then
the edit field is
displayedthe
svsten can be oPeratedlike
anornal typarriter
andthe text
aPpeals continuously onthe
screen.stonen ( 100x 100 )
S,l{ustsnen
I
SIJRW 76 IDITfiR i.ö. s" 198SåssunE $$r{ åhat, t*P hsve typed has been taken
frsn
Fayne i"S77,0iag*ä"#
the {sllnuing text: {This
Examp le p"106, )(C ) 19?9
S,f'lustonen
{ 100x 100 }$URUO ?6 HSITilR l.
e ö 4 5 6 7 ä
s
1S 1å
Ån
TC
t3
14
t5
16 å?
1fi 1S ä0 ä1
,"1 J.l
cc ds
*
*
*
f
*
Exarrple 1:
l-og-Lineår models {nr
Cantiggncy tab lps*
*
Thefslln*ing
dataåre
takenfrnn å
survey sS itre*pslitical attåtudes sf a
sampleof BritiEh
electsrE*which
is
reptlrtedin
But,ler and Stokes (1974),*He examine
the the
relatisnships
åiltolg{our
våriab les:*vote,
gexr
c Lagg and Ege"-
*
#
*
*
*
*
*
*
*
*
*
*
Lei
usnqr
considet sonetext editins fEcilities. 0n line 5
$e have an obviouserror in the
trord 'CsntigEncy' chere one'n' is
rissing.
Toinsert this letter
$e novethe
cursor{ron the
presentposition on line
11ts the point o{ insertion
by using F-kevslith
årross indicating the direction,
nanely, F5!(upwards)" FGi{dOlnnards}'Flä!(to the rishi)
and F13:tt'othe left).
lle
have thenthe follorinS display (only essential lines åre
Presen*ted
{rom noc on):0isp,3.4
5 *
Exanple1: Log+inear
nodelsfor
Contigency tsbles6* 7 *
The{ollorinE
dataare
takenfron a
surveyo{
theI *political attitudes o{ a salPle of British
electors9 rnhich is
reportedin Butler
and Stokes (19?4).l0
*Se eraninethe the relationshiPs arorg fsur
variables:11 rvote, sex, class
and age,12*
äftd
insertion
tekesCI..&äp.',* t 5
5 *
ExampIe
1:place by FrpgsinE key
F10!tinseri)
o$ce:Lsg-Lineär models
for
f,snti*gency tables åndtypins the
misEing'n'
:[:ser3'S
5 *
Exauplel; Lsgtineår
nsdel,s{or
Coniingenry t'ables7
S, |lustsnen
I
SURtl0 76 [S ITfrR
10. 8. 1980Correspondingly
the extra 'the' on line
10is
renoved by noving the cursonto that line at the
second'the':
0isp . ?. ?
5 I
Exanple1: Log+inear
nodelsfor
Contingency tables6* 7 x
Thefollsing
dataare
taken{ron a
surveyof
theI *political attitudes o{ a
sanpleo{ British
electors9 *rhich is
reportedin
Butlen and Stokes (19?4).10 ille
exaninethe lhe relationships
ånong{our variablesi
11 *vote, sex, class
and age.le*
and pressing key
F9:(delete) {our tines!
Oisp,?.8
l0
rUe exaninethe lelationships
anong{our
variablEs:For
thesecorrectisn
andeditins
purposee EDIT0R provides several neanscontrolled
by F-keys, A thoroughdescription o{
thoEeactiviiies
nill
be givenin
chapier 3.Besides these
'so{t keys'
EOIT0R includes,nanyeditins
sperationsfor
nore conplicated tasks.For instance, if re like to
nåkethe text nider in the edii {ield
soihat the preseni lines
?-11 should be longer upto
55 chanacters ue achievethis siiuation
bytyping
operation TRII{ ?,11,65 on eotreerpty line o{ the field (Iine
13in this
case)i0isp.ä.9
5 *
Eranple1! Logtinear
nodels{or
Contingency tables? * 5*
Thefollsing
datasre
tåken{rol a
survgyo{
theS *political attitudes o{ a ealple o{ British
electors9 lt*hich is
reportedin Butler
and $tokes t19?4).10 rte
exaninethe relationships
auongfour
variahles:1l *vote, gex,
clasg and age,lET 13
*TRIl,l ?,11,65_14*
and keeping
nqr the
cupeopon line
13 and pressing key C0NTINIEre obtain the {olloring result
Oisp.å,
t0
5 * Exawle li Logtinear rodels {or
Contingency tables6'* ? x
The{olloring
dataare
taken{ron a
surveyo{ the political
S *attitudes of a
sånpl,eo{ British electors nhich is
repErtedin
I *Butler
and Stokes (1974), Seexaline the relationshipE
anong {our10 *variables: vote, såx,
class and age.11 *
u
*TRII{ 7,11,65-13*
Since
the
ner nidenedtert
requireE ongline less
thEnihe original
one
our
TRII{operation
locates nqr online lä.
Te
lay
contiunuethis irinning
ppocess and uakethe risht
edgeof the text on lines
7-10 even byinserting extra
blanks betneen sonecords. This is
accomplishednost easily
byediting the
TRII{ speration online lE in the folltxring {orn {only'å'has to
beioserted):
0iEp.P.11
u
rTRIile_?,11"65S.l{r,stgnen: SURW 76
EDIT{}R
10. B, 1990and
activating this
operation againwith
I0NTINIE:Disp.?,U
5 r
Eranple1!
Los.Linear sodels{or
Contingency tables6* 7 x
The{otloring
dataare
taken{ron å
surv€yof the political I *attitudes of a sanple of Eritish eleciors shich is reported in
9 *Butler
and Stokes (1974), He exarinethe relationships aong
{our10 *variables: votg, ser, class
and age.11 *
le
*TRIile_?,11,6513*
tlbserve
that the editing
operatiansare
typed andedited like
nornaltert, but
eachline
containingtert
can beactivEted
by noving theculsor to ihEt line
and by pressingCtlilTll{$.
Then,i{ the line
can beinterpreted
esa valid operation, this
operationnill
becErried
out,but if the line
containEtext rhich
doesnot
comespondto
anediting operation,
nothingrill,
happen.Activation
cantake
placerany tires,
sincethe
operationtert
renains
in the field until it is ovencritten or
renoved by keysFå5;(delete line),
F8!(erase)or
byediting
operationslike
CLEAR and scRATCt{.The
poEition o{ the
operationnith
respectto the ohject of the
ope-ration is irraierial in principler In practice, hsever, it is iypical to
placethe
operations onlines
closeto the text
and dataio
behandled.0n the other
handit is pro{itable to collect
sone general operationslike
PRII{T(printout o{ selected lines or chapters),
SAVE(såving
the edit field)
and L0å0(Ioadins
sorerelated fields) to
thefirst lines of the {ield.
I{ re nu like to
saveihe current situation in the edit, {ield
ondisk se
cantype the
operation SAI/E ELECT0RS onthe {irst line:
Disp.?.13
1
*SAiJE ELECTORS-er 3*
4* 5 *
Exanple1! Logtinear
nodelsfor
Coniinsency tables 6and by
activating this
operationthe rhsle field nill
be savedin
file
ELECT0RS onihe user's
datadisk.
The S|JE operation does notaffect the
contentsof the field
andse car
continuethe job frm
the
presentsituation, but if
nE rakea
seriousernor like
an un{ortu- nate SCRATCHor
CLEAR openationuhich partially or cowletely
destnoysour texi, the situation
before savingnill
be restored bytyping
andactivating a
L0AD ELECTORS operation.The
sile
proceduneapplies
rhenre like to
breakthe job {or
auhile; re
savethe {ield
andrecall it later
bya
L0A0 operation.S.l'lustsnBn
I
SURU0 76 ED ITOR
10. S" 1980In order to print the lines
5-10 on paPer $etype the
oPerationtålll.3:il
on'oile enPt' rine:
1
SURUCI 76 ED IT0R
tC ) 1979S,l{ustonen
t 100x 100 }1
*SAVE ELECTORSe* 3
*PRIllT 5,10_5 *
Exampleli Logtinear
nodelsfor
Contingency tables6* ? r
Thefollqring
dataare
taken{ron a
surveyof the political I xattitudes o{ a sanple o{ British electors rhich is reported
in9 *Butler
and Stokes (19?4).Ie
eraninethe relationEhips
anong four10 rvariablesS vote, sex, class
and age.u llr
*TRIile ?,11,6513*
and and
a{ter activation obtain the folloning
output onPrinter:
Exanple
1! Logtinear
nodelsfor
Contingency tableeThe
folloring
dataare
takenfron a
surveyof the politicat
aititudes o{ a sålple of British electors rhich is rePorted in Butler
and Stokes (19?4). He exaninethe relationships
among fourvariables: vote, Eer,
clågg and age.In that
outputthe line
nunbens andthe contrsl colurn {illed rith
asterisks
donot
äppear.So
{ar this
has beenonly introduction io the norlal text editing
facilities o{
SURTO ?5 EDIT0R.l{or se trv to illustrate the possibili- ties {or
handlins data sets andstatistical
oPerations.He
shatl
continueour
exarple on contingencytables
next by enteringthe four*ay table to
be analyzed:I
*SAiE ELECT{IRSe* 3
TPRINT 5I1O4r 5 *
Exanple1: Logtinear
nodelsfor
Contingency tables6* ? *
Thefolloging
dataare
taken{ron a
surveyo{ ihe political E *attitudes of a sanple o{ British electors
nhichis ieporied in
I *Butler
and Slokes (19?4), Se exaninethe relationships
anong four10 *variables: vote, sex, class
and age.11 r
The vEriahlesare
de{ined andthe
ohservedfrequer'-''
åreU *given in the {our*ay table
belor.tg* 14 *
0BSERI'ED FRE0IEIICIES F0R t{lTE BY SEX BY CLASS BY AGE (l{=L?S?)15* 16*
1? * Sex l{ale
Fenale1g * Uote
Cons Labour Cons Labourtg *Class Age ***{**
e0* eI *uPpet 173 4 0 10
0e?. * 51-rJ 2? I e6
9t3 * 41-50 2? 4 e5 9-
Shen
entering ihe
eleurentso{ the table
tre reachfor the first tine
the last line of the
gcneen,but
ne can continuetyping nornallv'
S,ltustonen
:
SURW ?S ES IT{}R 1,0. s.1980since the
f ield iE
scrs 3,linga$ter typing the last
linessq,sEnP.
{f
1
SURUO 76 EOITORauåsmatica I
ly
åccordingof the
table
$e Frave the(C ) L9?9 S.1{ustonen
ts
orirr needs andd isp iay : (100xt00)
16 L7 18 19 äs
f1 {
gÅ
flf-t
c,c
e3 ä4 e5 e6
?7 ä8 e9 3ö 31 33 33 34
s
36 3?
*
*
*
*C
lass
åge*
Ser
l{ale
Fena leUote Cons
Labour Cons Labour******
In srder to
nånipulate thiE
table gith cal
aperations Beleve to insert å
TåBLEli*e of
t he Sield ta
natural
p laceis in
line
161:oågr nflr.13
469 100 e59 Pg9 73 33S 9e
e94 1?
13137 5e 1?4
533A
7036
6?1g
33vårisus editing
andEtatisti- speci{ication to
åny enpty{ront o{ the
tablel
here sn*upper
*
*
*
*
*
e78 40 274 t"? $
76 al 84 ffi
a7H 14
1599 35 815
6eg9
753A
6614
34)73 51-?3 41€0 a6-40 {86
*
lcmer
) ?3*
51-?3*
41-50*
ä6-40r
{€5*
*sonk
) ?3r
51-73*
41"-50*
e6-40*
-ä6{lbserve
that se
canrepr€sert a rultisay tablE in
nornal {ashion.The
structure s{ the iab}e is
defined bythe claFf,ifiFrs åse,
Class Uoie and 9exnhich
can be'traced hythe aid o{ the strins *r****
s1Iine 19,
The nurberof
aEteriskspoints out the
nunbero{ the mximl class
narein
use.16 L?
18 19 e0 e1
??,
e3 e4 a5 e6 p7 ä8 äs 30
3t
3ä 33 34 35 36 3?
*TAH-T PAYI{E, I.? ,37,F*
* Sex
l{ale
F ena le* Vote Cons
Labour Cons Labour*f,
lass Age *'r****
*
* upp er
*
*
*
*
*
)?3 51-?3 41-50 a6-40 {p6
*
luser
) ?3*
51*?3*
41-50*
e6-4 0*
{46*
*sork
) ?3*
51*?3*
41*50*
e6-40*
{å6?,7 I 40 374 1?$
76 g4 Pl
13?7H 14
1599 35 915
6ee9
?53e
6614
34e69 100 e59 a89 73 338 9?.
e94 17
13137 51 174
533e
?036
6718
33TABLE PAY}IE, 17,3?, F PAYNE ånd
locating
onon line
16 de{ines n$ilå
nultiway
table
called
lines
1?-3?. Thelast
paraneterF in
i,he TABLES. iluEånnen
I
StiRtlS ?6 äS ITSR tro" 8.1990de{inition
annou$cesthat ihe
elementsof this table
should beinter-
preted
as
{reguencies. (Another coilnonalternative ir a
data tableconiaining
valueso{ a certain variate
accordingto a nultiray clas-
sificationi
thense
have X insteado{
F. )EOITOR provides vatious neans
{or nodi{ication s{ nulliway
tables.lde can conbine classes
sf
anyclassi{ier'
change placesof classi{iers
in the table, {orn narginal iables
bycollapsing
over someclassifiens
and conputerith
thesenodifications
asrell
asnith the original
one-A
set of
TAB-operationE enahlesa great varietv o{ table
rePresenta-tions
and reductions.Here ne
can, for instance,
collapse overthe
Agevariable
by enter-ing a
TABD operationiDisp.P.18
SURUI} ?6 ED I TOR (c ) 19?9 S,l'lustsnen ( 100x 100 )
3t
3e
FtFt
ö...1
34
s
36 37 38 39 40 41 4A 43 44 45
31
3?.
33 34 35 36 37 3g 39 40 41 4e 43 44 45 46 47
*
*
*trlork
*
*
*
*
*
* TAFO
*
*
*
*
*
*
99 35 s15
6eä9
?53A
6614
34137 5A 1?4
533A
?036
6?18
33.f6
)?3 51-73 41-50 ä6"4 0
*ä5
PAYl,lE,AgF,40*
ThiE gFeråtion has indicai,es
the'{irst
disp lay I siEp". t.,.13
been tyPed on
line
39 åndline {or the
result'
Thisthe last
påråseter 4 0operåti.sn leads
to
åSURI$ EA ITOR tC ) 19?9
$.l{ustonen
t 100x 100 }*
{96*
*rork
) ?3*
51-?3*
41-50*
e6-4 S*
-iggT
ITAffi FAYt'lE,Age,40*
*TABLE FAYNED,41,46,F
* Sex
f'lale
F eura le* Uote ConE
LabourCons
Labsur*C
laEs **t***
*upper 8e 30 96
30*
l$ser ?9 53 101
34*work 118 ege 155
ee?*
I
g
Ba9 3e 14
9137 151?4 6e 5e
53?5 3A
?066 36
6?34 18
33nhere
tle
havethe
requiredthree*ay narginal table autmatically Iabelled uith
an appropriate TABLEde{inition
online 40.
The naueof this
neu table is
generated bv addingthe fourth letter
{nonthe
TAB-operation used (here0) at the
endo{ the original
nane PAYNI.Thus subsequent operations $av
refer to this
neutable
by nane PAYi'|ED.$. Fårrsto$ff$
s
$URUS ?6 US IT{3R
å0, S,, åSSS TOFor the analysis of
continsencytables
SUR'{I ?6 EDIT0R includes TAB-FIT
operaiionrhich
can be usedfor estination' o{ log-linear
nodels.(For these nodels see
s.9.
Payne 19?7, Bishop,Fienberg,Holland 1975,)If re like to estirate a log-linear
nodelfor table
PAYilEO assuningttrat
Sex, Class and Uoteare
independenl Eespeci{y this
nodelin
ihefollcing
nay:Oisp.P.?0
40
TTAH.E PAYilEO,41,46,F41 * Sex l{ale
Fmale4ä * Uote Cons
LabourCons
Labour43 *Class ****I*
44 *upper & 30 96
3045 *lorer ?9 53 101
3446 *uork 118 Ase $5
ee74?T 48
TTASIT PAYilEU,49,5O49
*L0GLllt C,U,550*
Here
the TAffIT
Eperationspecifies the table to
be analyzed tPåYl,lE0),ihe linE de{ining the rodel (49},
andthe line for the re- sulis (50).
The independenceo{ classi{iers irply that the
one-dinen-sional uarginals for [lass (C],
Vote (V) and SextS] nust
befired in the estimtion of ihe
erpected frequencies,This specification
corres- pondsto the
comsnXfä-test {or
independence andit is
typed on theline
49in ihe forn
L0GLIi{ C,U,S. 0hservelhat the initials of
eachclassifier
shsuld be usedin this specification,
Activation of line 48
leadsto the results!
DLsp.2.?L
40
TTAFLE PAYIIEO,4I,46,F41 * Sex l{ale
Fenale4? r Vote Cone
LabourCons
Labour43 *Class f*t*{r
44 *upper ge 30 96
3045 *lorer ?9 53 101
3446 *rork 118 ese l55
ee?48 47*
*TABFIT PAYIIES,!9,5049
*LoGLIil C, r/,550
16lä= 165,040F=
7 P=0,000 FITTE0:C,U,S
tPAYllE0)51
*TASLE PAYI{EDF,5E,5?,F5e r Sex l{ale
FEnale53 * Vote Cons
LabourCons
Labour54 *Class ***I*I
55 *upper 5g 58 61
6156
rlser 65 65 69
685? rrork 184 183 193
19e58r
0n line
50re
havethe goodness-of-fit statistics {or the
nodel andon
lines 5t-57 the tatle o{ {itted
{requncies. As expectedthis
nodelis very
poor and ue haveto
continue bytrying tore
conplicated ones.Here se nake
just
one noree{{ort
andestinate a
nodel uhereit is
assuled
that
Classis
independentof
Sex given Vote.This inplies fixins the
tuo-dinensionallarginals
VS,t,f,.To
estiute this
nodelre edit the lines
48 and 49to the
{ornDisp,l.fl?
48
*TASIT PAYI{E0,å9,5149
rL06LIil US,TJCindicatins ttlat the reEults are to
åppearfron line
51 onnards.Activation of line
48 once again produces:$.f'tuEtsnen 3 SURVil 76 tS
IT0R
10,8. 19S0 11Disp,P.?3
40
*TABLE PAY}IE0,41,46,F41 * Sex l{ale
Fenale42 * Uote Cons
LabourCons
Labour43 IClass ******
44 xupPer Be 30 96
3045 *loner ?9 53 101
3446 *work 118 ese $5
ee?48 47*
ITABFIT PAYNED,49,5I49
*L06LIN U5,tC50
*G+A: 165.04DF=
? p=0.000 FITTEo:c,u,s
(PAYllEo)5l *Gl?=
P, ?60F= 4
P=0.60? F ITTED: US,VC
(PAYI'IED )5E
TTABLEPAYNEDF,53,58,F53 * Sex l{ale
Fenale54 * Vote Cons
LabourCons
Labour55 IClass ****I*
56 rupper ?9 H 99
eB57 rlorer 80 47 100
4058 *Eork $1 e56 $e
22359*
The previous
results on lines 51€? are evernritten
hythe
ne$ oltes.The
{it
descrihedon line
51is
nos good.I{
tle nantto
havethe fitted
frequencies note accuråtelythis is
achieved
sinply
byediting at least
one elenentin table
PAYilEDto
a{orn
correspondingthe
accuracy desired and hyactivaiing
TABFITagain.
Thus
by editing line
58lenporarily into the
forn46 rwork 1lS ASg $5
eA?,00and by repeating TABFIT ue
get ihe results in the
{orn:0isp. å. fl4
40
*TASLE PAYI{E0,41,45,F41 * Sex l{ale
Feuale4g * 9ote Csns
LabourCons
Labour43 tClass ****l*
44 rupper H 30 96
3045 *Iouer ?9 53 101
3446 *work 118 ese 155
ee7.004g 47*
*TABFIT PAYNED,49I51-49
iL0GLIl,l VS, t/C50
*61ä= 165.04DF=
7 P=0.000 FITTEO:C,U,S
(PAYI{EO}St .*Gf?=
3.?60F= 4
P=0.608 FITTEo:US,VC
(PAYI{E0)5E
*TABLE PAY}IEOF,53,5B,F53 * $ex llale
Fenale54 * Vote Cons
LabourCons
Labour55 *Class ******
56 *upper 78.70 3e.11 99.30
A7'Bg57 *lcxrer ?9.59
46'56100.41
40.4458 *sork $0.?1
456,33 15e.ä9 AeA.6759*
Thereafter
the residuals
can be {srnedsinplv
bya
TAF- oPeraiion:60
*TAB. PAYNEO,PAYI{EDF,61*and i.he
result is:
S.l'lust$llen: SURIffi 76
EDITfiR
10.8, 1980Disp, P.?5
59* 60
TTAB- PåYI{EO,PAYI{E0F,61.61
*TABLEPAYI'IEOF-,6A,67,F6e * Sex l{ale
Ferale63 r Uote Cons
LabourCons
Labour64 *Class II****
65 ruppEr 3.30 -4,11 -3.30 e.ll 66 *lcrer -0,59 6,44 0,59
-€.4467 *uork +.?1 -4.33 9.71 4.ffi
6gt
Thes€
'r*' residuals
could benornalized (for
instance bydividins
theo by
the
squareroots of the
erpected {requences)in a {en editins steps, but re stop
ouranalysis
here.At this
stagethe lines l-6? o{ the edit field are filled
by auixture o{ text, data, results
andediting
operations. lle nay såvethe
presentsituaiion
ondisk
byrpturning to the first line o{
the*ield, This is
achieved by pressing key F?31(previsus page)a
coupleof tines
and byartivating the old
$AtE ELECT{IRS operationsn linE
1:Disp.ä,PE
I
SURt/t] ?6EDIT{IR
(C)19?9S.l{ustonen
t100x100}1
*SåUE ELECTORSar 3
*PRINT 5,104x 5 * Erarple li Lostinear
nodelsfor
Contingency tables6* 7 *
The{ollwing
dataane
taken{ron a
Eurvgyo{ the political I *attitudes o{ a sårple of British electors nhich is reported in
9 *Butler
and Stskes (1974). Se eraninethe relationships
anong. four10
*vaniables3vgte, ser, class
and age.11 *
The variableEare
defined andthe
observed frequencies areU lgiven in the fourtay table belol.
13* 14 *
0BSERttr0 FRE0III{CIES FOR U}TE BY SEX BY CLASS BY AGE (il=1ä57)15* 16
*TAH.E PAYilE,1?,3?,F1? x Sex l{ale
Feu1e18 * Uote
Cons Labour Cons Lebour19 *Class Age l*I***
POT ei *upper )?3 4 0 10
0?? * 51-73 e7 g e6 I e3r{1t0274e59
To take
a
ner*printout of the essential lines, the
PRINT opprationon line 3
should beedited to forr
PRINT 5,6? and aci,ivated.In order to lake this
output cleanit
can be purged{ron editing
operations andtechnical
lineErith Få5:(delete line)
and F8:(eraseline)
andall the relevant
connentsray
beinserted
aaongthe tert.
Then none
lines are
neededfor
suchinsertions
keyF25:(insert line)
is to
be enployed.In
nany casesit is corth rhile to
prsservethe editing
operaiionsduring the analysis
ståge andnoi to
cancelthen, If the editing
oper-ations are le{t in the edit field it is usually
easyto rork out
thesale probler uith
another dataset just br
changingthe data
lineE andby
activating the old
operationlines.
In
teachingsituations it my
be valuableto delonstrate the
e{{ectso{ various
changesin the
dataset to the results
by repeating the stepsof analysis sith
dataedited in
various uays.1ä
S.ltustonen
:
SURI$ ?6E0ITOR
10,8. 1990 t33.
Useo{ edit
kevsllhen EOIT0R has been
called frou
SURUT ?6 andthe
basicstårt Fl ie
takenthe
F-keys operateas {ollms:
F0: List of F-starts (as in other
SURV0 ?5 mdules)Fl; exira
charactenl, default is 'å'
F?i
extpa character?, default is 'ö'
F3:
UNDERLINIilG 0l{/0FF: Thenexi
charactersto
be tvpedrill
beprin- ted (printer
?231-S3) underlined,'A{ter
Pressing F3 asain thenexi
charactersuill
beprinted rithout
underliningF4:
(END) novesthe
cursorto the right
endo{ the
CRT.F5:
(annon durn) novesthe
cursor oneline
donnEards.F6; (arr$
up) novesthe
curEor oneline
uPrards.F?:
(EEGIN) novesthe
cursorto the le{t of
endo{ the
CRT.F8:
(ERAS[) erasesthe line to the right frou the
cursor.F9;
(DELETE)deletes
one character.F10:
(INSERT)inserts
spacefon
one character.F11: (---) )
novesthe
cursor5
stepsto the rishi,
Fll: (-))
novesthe
cursbr one stepts the right.
FL3: ({-)
novesthe
cupsor onestep to the left.
F14: ({---)
rovegthe
cursor5
stepsto the left.
If the
edgeof the
CRTis
surPassedin
these rsvesthe visibte part of the edit {ield rill
be noved corresPondingl!t,F15i
cspieE onetirid to the current line starting {rou the
currentposition of the cursot, åfter
Pressing F15the
questionLIIIE
(N0.)
T0 EE C0PIED?rill first
be displayed'Fl6i inserts liåEing rords
tyPed asthe next line to a
Place pointedout
byihe cursor.
Observethat a
nornal Procedurefon linor insentions is to
use Fe6 (IIISERT) repeatedly.Fl?i exira
character3' default ig 'ii'
FIB: extra
chanacter4, defauli is 'ii'
Fl9: iypes
charactetE nhichate lirsing
onthe
keyboard.After
F19the
quesl,ion {--{EX80I}E?rill
be displevded andthe
user hasto enter the
hercodeo{ the characier.
The hexcodesare listed
in appendirF o{ the
'9900 tl? BEsic-8 Language Reference ltanual'.Fe0:
(EilO)loves the cutsor to the bottsr line of the
CRTF?1: (arron doln) displays the
next Page onthe
CRTF€€: (arrm up) displays the
Previous Page onthe
ERTF83: (HGIill rcves ihe
cursorio the {irst line o{ the
CRTF84: (extra character)
operates asFl9
rhen used{or the {irst tile.
Thenea{ier FP4 types
directly the
selectedcharacier.
Toalter ihe
extna charactErerit
andselect
EOITOR again.Fa5:
(oELETE) deletesthe current line,
FP6: (I|{SERT}
inserts a
ner enPtyline after the current line' Fe?: {---}) displays lhe right side o{ the edit {ield,
Fe8: {-) } displays the right side of the edit {ie1d'
FAg:
(d-)
uovesthe
cureorto the sl,art of the current line'
F30: ({---)
novesihe
cunsorto the start o{ the current line'
5" llustone$
:
SURtJtl 76 EDIT{IR
10. S, 1990 14FSli rcves the
cursorto the control coluta 0
indicated,noraally
by anasterisk *. Erit $rm tha control iolum,takes
plece'by'usingthe arrql
keysFll,FlE.
The charactersin the control
coluln havethe {ollqring
tasks:char.
task- in
PRII{T operationthe line rill
beprinted rith
elongated characl,ers,
s the nert line
feedtin printer
?P$1il-3)is
1/3of a norral line {eed' This
feEtune,cåR beugåd
'for typing
exPsnents,indices
etc.?5 *
For exalPleIt F uarisbleE *itt, xåo',-.', xli) ' :
,80 * (nert line)
q ås s, tut onlv a lll? of e lonal tine
{eednr es s, but only a 1/6 o{ e norral line
{eed'tstårtsan*p"g*rhenthqoitenoel{orro{.FRIllT
operatisn
is
used,5, ilustonen
!
SURtl0 ?6EOIT0R
10. 8. L9804.
Texteditinq
In this
chapter neshall
consider hasic operations neededin text
and data nanagement,4,1
Clearinqthe
edåt.tield
Clearing o{ single
characters andlineE
takes place bythe
keys:F9: delete
one characten, FAs:delete oneline,
F8:
Eraseline to the right. o{ the
curgorI{ the user likes to clear the field partially or
conPletely duringthe nork
he can enploy SCRATCH, CLEAR, ERASE and DELETE operations.SCRATCH
(rithout
any paraneters)clears the edit {ield
{nsnthe
SCRATCHIine
onsards.CLEAR LT,LE
uhere
Ll
and L3are line
nuuberE and'Ll(=Låclears the lines Ll-Le.
CLEAR xy
clears a
rectangularsub{ield indicated
bythe
character xin the left rpper
corner andy in the right lgler corner'
The characters used{or fiEld indication (xy} nust
be uniquelv dE-ternined in the edit {ield.
For iustance, if re activate
CLEAR*+ in the follo$ing situation:
Disp .4.
I
I
SURU(I ?6EDIT0R
(C)19?9.S.l{ustonen
(100x100)3gr 39r
40
*TABLE PAYiIEO,4I,46,F4l * Sex l{ale
Fenale4A * Uote Cons
LabourCons
Labour43 *Class ItIt**
44 *upper 8e 30 95
3045
*Ialer ?9 53 101
3446 *norlc 119 eW, $5
8fl? +4g 47*
*CLEAR r+_49*
nothing happens, since
* is
aubiguous,but insention o{ I a{ter asterisks
online
43Disp.4. ä
l.
.jFURt$ 3$ EQIT0E-- (EU9A S.ilttstonen
(100x100)38* 3r9*
40
*TABLE PAY}IED,4T,46,F4l * Sex l{ale
Ferale4A * Vote .Csns
Labourf,ons
Labour43 *Class ****** I
44 *uPPer m 30 96
3045 rlorer ?9 53 101
3446 *nork 11g eSP $5
ää? +48 47*
*CLEARI+-
49*
15
S.l'lustonen
:
SURlfil ?6EOITOR
10. B. 1980 16and
activation of
CLEAA $+ online 48
leadsto
PlEp
'4.3
I
SURt/tl ?6 EDIT0R
(C ) 1ä?9S,l{ustonen
( 100x 100 }38* 39*
40
ITABLE PAY}IED,4I,46,F41 r $ex l{ele
Fenale42 * Uote Cons
LabourCons
Labour43 IClass ***III 44
*upper45
rluer 46
*uork48 47*
*CLEAR T+-49r
A
third {orl o{
CLEåR operationis
CLEåRLl,Lg,K rhich clears
thelines Ll-Lå for
those colunns chichare
indicEted by non-blanlt charactersin
oniraEe line K.
Considenthe situation:
Disp,4.4
I
SURUI ?6EDIT0R
(C)19?9$,i{ustonen
(100x100)40
*TABLE PAYNEO,41,46,F41 * Ser ilale
Femle4e * Uote Cons
LabourCons
Labour43 *Class *I***I
qq *upp"t Ba 30 96
3045
*lmer 79 53 l0l
3446 *rork Ug esg $5
Ae?47 * XXXXXX
XXXXX4g
*CLEAR 4A,46,4?_49* 50*
Execution
o{
CLEAR 44,46,4? givesi0isp.4.5
40
TTAH-E PAYilEO,41,46,F41 r $ex ilale
Fenale42 * Voie Cons
Cons43 *Class ******
44 rupper W
9645 lltrrer 79
10146 *rork ltg
f5547 * XXXXXX
XXXXX4g
rcLEåR 4e,46,4?-49* 50*
In
EOITORthe
coluunsio
be processedare lever referred to
bvcolurn indices, but
inagelines are
usedto Point out the
colunns involved.The ERA$E operation
is to
be usedfor
erasing selected charactersin the {ield.
EM$E
(string)
erases
all
characters occuringin (string) fron the edit {ield.
For instance, to
eraEeall
nulbers execute ERASE U3456?8t)0.The OELETE operation
iE a seneralization o{
kevF9l(delete)'
OELETE LI,LE
deleies the colurn indiceted
bythe
cursorfron the lines
Ll.Läsirulteneously,
Thusthe current
colunnuill
belost
and theS"l{uEtonen
!
SURt'0 76EDIT0R
10.8. 1980 1?colunns
to the right
fromthe
cursor areloved
onestep io
thele{t.
4.3.
l,loyiTq.Jartsof the edit {ield
For
variousinsertions in the edit {ield se
can usefollosing
oper- ations.II'ISERT Ll,LP
i,nserts one enpty
coluln to the current position o{ the
cursorfor the lines Ll-LE sinultåneously.
Thusthe
colunnsio
theright of
thE cursor are loved one stepio the right,
Thus INSERT
is a generalizaiion of
keyF10l(insert).
For exanFle, byactivating
INSERT 41,46 online
48{ive tines
Disp.4.640
*TABLEPAYI{ED,41,46,F41 r Sex l{ale
FenEle4e * Vote Cons
LabourCons
Labour43
*Class I**I**
44 *upper H 30 96
3045 rlocer W 53 101
3446
rtlork tlg e5å $5
3?74g 47*
*II{SERT 41,4649*
tre
shall
have:0isp,4. ?
40
*TAH-E PAYl,lE0,4t,46,F41 * Sex l{ale
Femle4e * Vote Cons Labour ConE
Labour43 *Class ******
44 *uPPer 8P 30 96
3045 *Isrer ?9 53 101
3446 rnork 118 Psg f55
2e74g 47r
*It{sERT 41,4649*
CIIPY Ll,LE,L
noves
lines Ll{.ä to a nel
placEstarting {ron line L,
The pre-vious contents
of lines L,L+1,..,,L*L8{1+l rill
be destroyed.0bserve
that {or
novingsingle tines it is silplest to
use key F15.The l{01tr operation
is a generalization of
C0PYpernitting
various rectangularsubfields to
be copiedin the edit {ield.
l{0t/E has tso {orns.l{0trE xyz
noves
a sub{ield indicated
by characterx in the le{t
uppercor-
ner and charactery in the right lsrer
cornetto a
placeindicE- ted
by characterz
sothåt r uill
bein the position o{ r.
Theindicators x,!r,r nust
be unanbiguouEiotherrise the the
l{0ttE xyzopEration
is not carried
out,il{IUE
- -
L1,LE,K,L;;;;; a
sub+iEtdfror the lines Ll.Lä to lines sterting {ror
L, The colunns uhichare to
loved andto rhich colulns are
sPeci-fied
by an inagEline
Kconsisting of at least tno X'e
and oReY,
The colurnsto
be rovedare
detenrined bvthe first
andlast
X and