doc: Generate output for tutorial examples at build time too.
[pspp] / doc / tutorial.texi
1 @c PSPP - a program for statistical analysis.
2 @c Copyright (C) 2017 Free Software Foundation, Inc.
3 @c Permission is granted to copy, distribute and/or modify this document
4 @c under the terms of the GNU Free Documentation License, Version 1.3
5 @c or any later version published by the Free Software Foundation;
6 @c with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
7 @c A copy of the license is included in the section entitled "GNU
8 @c Free Documentation License".
9 @c
10 @alias prompt = sansserif
11
12 @include tut.texi
13
14 @node Using PSPP
15 @chapter Using @pspp{}
16
17 @pspp{} is a tool for the statistical analysis of sampled data.
18 You can use it to discover patterns in the data,
19 to explain differences in one subset of data in terms of another subset
20 and to find out
21 whether certain beliefs about the data are justified.
22 This chapter does not attempt to introduce the theory behind the
23 statistical analysis,
24 but it shows how such analysis can be performed using @pspp{}.
25
26 For the purposes of this tutorial, it is assumed that you are using @pspp{} in its
27 interactive mode from the command line.
28 However, the example commands can also be typed into a file and executed in
29 a post-hoc mode by typing @samp{pspp @var{filename}} at a shell prompt,
30 where @var{filename} is the name of the file containing the commands.
31 Alternatively, from the graphical interface, you can select
32 @clicksequence{File @click{} New @click{} Syntax} to open a new syntax window
33 and use the @clicksequence{Run} menu when a syntax fragment is ready to be
34 executed.
35 Whichever method you choose, the syntax is identical.
36
37 When using the interactive method, @pspp{} tells you that it's waiting for your
38 data with a string like @prompt{PSPP>} or @prompt{data>}.
39 In the examples of this chapter, whenever you see text like this, it
40 indicates the prompt displayed by @pspp{}, @emph{not} something that you
41 should type.
42
43 Throughout this chapter reference is made to a number of sample data files.
44 So that you can try the examples for yourself,
45 you should have received these files along with your copy of @pspp{}.@c
46 @footnote{These files contain purely fictitious data.  They should not be used
47 for research purposes.}
48 @note{Normally these files are installed in the directory
49 @file{@value{example-dir}}.
50 If however your system administrator or operating system vendor has
51 chosen to install them in a different location, you will have to adjust
52 the examples accordingly.}
53
54
55 @menu
56 * Preparation of Data Files::
57 * Data Screening and Transformation::
58 * Hypothesis Testing::
59 @end menu
60
61 @node Preparation of Data Files
62 @section Preparation of Data Files
63
64
65 Before analysis can commence,  the data must be loaded into @pspp{} and
66 arranged such that both @pspp{} and humans can understand what
67 the data represents.
68 There are two aspects of data:
69
70 @itemize @bullet
71 @item The variables --- these are the parameters of a quantity
72  which has been measured or estimated in some way.
73  For example height, weight and geographic location are all variables.
74 @item The observations (also called `cases') of the variables ---
75  each observation represents an instance when the variables were measured
76  or observed.
77 @end itemize
78
79 @noindent
80 For example, a data set which has the variables @exvar{height}, @exvar{weight}, and
81 @exvar{name}, might have the observations:
82 @example
83 1881 89.2 Ahmed
84 1192 107.01 Frank
85 1230 67 Julie
86 @end example
87 @noindent
88 The following sections explain how to define a dataset.
89
90 @menu
91 * Defining Variables::
92 * Listing the data::
93 * Reading data from a text file::
94 * Reading data from a pre-prepared PSPP file::
95 * Saving data to a PSPP file.::
96 * Reading data from other sources::
97 * Exiting PSPP::
98 @end menu
99
100 @node Defining Variables
101 @subsection Defining Variables
102 @cindex variables
103
104 Variables come in two basic types, @i{viz}: @dfn{numeric} and @dfn{string}.
105 Variables such as age, height and satisfaction are numeric,
106 whereas name is a string variable.
107 String variables are best reserved for commentary data to assist the
108 human observer.
109 However they can also be used for nominal or categorical data.
110
111
112 @ref{data-list} defines two variables @exvar{forename} and @exvar{height},
113 and reads data into them by manual input.
114
115 @float Example, data-list
116 @cartouche
117 @example
118 @prompt{PSPP>} data list list /forename (A12) height.
119 @prompt{PSPP>} begin data.
120 @prompt{data>} Ahmed 188
121 @prompt{data>} Bertram 167
122 @prompt{data>} Catherine 134.231
123 @prompt{data>} David 109.1
124 @prompt{data>} end data
125 @prompt{PSPP>}
126 @end example
127 @end cartouche
128 @caption{Manual entry of data using the @cmd{DATA LIST} command.
129 Two variables
130 @exvar{forename} and @exvar{height} are defined and subsequently filled
131 with  manually entered data.}
132 @end float
133
134 There are several things to note about this example.
135
136 @itemize @bullet
137 @item
138 The words @samp{data list list} are an example of the @cmd{DATA LIST}
139 command. @xref{DATA LIST}.
140 It tells @pspp{} to prepare for reading data.
141 The word @samp{list} intentionally appears twice.
142 The first occurrence is part of the @cmd{DATA LIST} call,
143 whilst the second
144 tells @pspp{} that the data is to be read as free format data with
145 one record per line.
146
147 @item
148 The @samp{/} character is important. It marks the start of the list of
149 variables which you wish to define.
150
151 @item
152 The text @samp{forename} is the name of the first variable,
153 and @samp{(A12)} says that the variable @exvar{forename} is a string
154 variable and that its maximum length is 12 bytes.
155 The second variable's name is specified by the text @samp{height}.
156 Since no format is given, this variable has the default format.
157 Normally the default format expects numeric data, which should be
158 entered in the locale of the operating system.
159 Thus, the example is correct for English locales and other
160 locales which use a period (@samp{.}) as the decimal separator.
161 However if you are using a system with a locale which uses the comma (@samp{,})
162 as the decimal separator, then you should in the subsequent lines substitute
163 @samp{.} with @samp{,}.
164 Alternatively, you could explicitly tell @pspp{} that the @exvar{height}
165 variable is to be read using a period as its decimal separator by appending the
166 text @samp{DOT8.3} after the word @samp{height}.
167 For more information on data formats, @pxref{Input and Output Formats}.
168
169
170 @item
171 Normally, @pspp{} displays the  prompt @prompt{PSPP>} whenever it's
172 expecting a command.
173 However, when it's expecting data, the prompt changes to @prompt{data>}
174 so that you know to enter data and not a command.
175
176 @item
177 At the end of every command there is a terminating @samp{.} which tells
178 @pspp{} that the end of a command has been encountered.
179 You should not enter @samp{.} when data is expected (@i{ie.} when
180 the @prompt{data>} prompt is current) since it is appropriate only for
181 terminating commands.
182 @end itemize
183
184 @node Listing the data
185 @subsection Listing the data
186 @vindex LIST
187
188 Once the data has been entered,
189 you could type
190 @example
191 @prompt{PSPP>} list /format=numbered.
192 @end example
193 @noindent
194 to list the data.
195 The optional text @samp{/format=numbered} requests the case numbers to be
196 shown along with the data.
197 It should show the following output:
198 @psppoutput {tutorial1}
199 @noindent
200 Note that the numeric variable @exvar{height} is displayed to 2 decimal
201 places, because the format for that variable is @samp{F8.2}.
202 For a complete description of the @cmd{LIST} command, @pxref{LIST}.
203
204 @node Reading data from a text file
205 @subsection Reading data from a text file
206 @cindex reading data
207
208 The previous example showed how to define a set of variables and to
209 manually enter the data for those variables.
210 Manual entering of data is tedious work, and often
211 a file containing the data will be have been previously
212 prepared.
213 Let us assume that you have a file called @file{mydata.dat} containing the
214 ascii encoded data:
215 @example
216 Ahmed          188.00
217 Bertram        167.00
218 Catherine      134.23
219 David          109.10
220 @              .
221 @              .
222 @              .
223 Zachariah      113.02
224 @end example
225 @noindent
226 You can can tell the @cmd{DATA LIST} command to read the data directly from
227 this file instead of by manual entry, with a command like:
228 @example
229 @prompt{PSPP>} data list file='mydata.dat' list /forename (A12) height.
230 @end example
231 @noindent
232 Notice however, that it is still necessary to specify the names of the
233 variables and their formats, since this information is not contained
234 in the file.
235 It is also possible to specify the file's character encoding and other
236 parameters.
237 For full details refer to @pxref{DATA LIST}.
238
239 @node Reading data from a pre-prepared PSPP file
240 @subsection Reading data from a pre-prepared @pspp{} file
241 @cindex system files
242 @vindex GET
243
244 When working with other @pspp{} users, or users of other software which
245 uses the @pspp{} data format, you may be given the data in
246 a pre-prepared @pspp{} file.
247 Such files contain not only the data, but the variable definitions,
248 along with their formats, labels and other meta-data.
249 Conventionally, these files (sometimes called ``system'' files)
250 have the suffix @file{.sav}, but that is
251 not mandatory.
252 The following syntax loads a file called @file{my-file.sav}.
253 @example
254 @prompt{PSPP>} get file='my-file.sav'.
255 @end example
256 @noindent
257 You will encounter several instances of this in future examples.
258
259
260 @node Saving data to a PSPP file.
261 @subsection Saving data to a @pspp{} file.
262 @cindex saving
263 @vindex SAVE
264
265 If you want to save your data, along with the variable definitions so
266 that you or other @pspp{} users can use it later, you can do this with
267 the @cmd{SAVE} command.
268
269 The following syntax will save the existing data and variables to a
270 file called @file{my-new-file.sav}.
271 @example
272 @prompt{PSPP>} save outfile='my-new-file.sav'.
273 @end example
274 @noindent
275 If @file{my-new-file.sav} already exists, then it will be overwritten.
276 Otherwise it will be created.
277
278
279 @node Reading data from other sources
280 @subsection Reading data from other sources
281 @cindex comma separated values
282 @cindex spreadsheets
283 @cindex databases
284
285 Sometimes it's useful to be able to read data from comma
286 separated text, from spreadsheets, databases or other sources.
287 In these instances you should
288 use the @cmd{GET DATA} command (@pxref{GET DATA}).
289
290 @node Exiting PSPP
291 @subsection Exiting PSPP
292
293 Use the @cmd{FINISH} command to exit PSPP:
294 @example
295 @prompt{PSPP>} finish.
296 @end example
297
298 @node Data Screening and Transformation
299 @section Data Screening and Transformation
300
301 @cindex screening
302 @cindex transformation
303
304 Once data has been entered, it is often desirable, or even necessary,
305 to transform it in some way before performing analysis upon it.
306 At the very least, it's good practice to check for errors.
307
308 @menu
309 * Identifying incorrect data::
310 * Dealing with suspicious data::
311 * Inverting negatively coded variables::
312 * Testing data consistency::
313 * Testing for normality ::
314 @end menu
315
316 @node Identifying incorrect data
317 @subsection Identifying incorrect data
318 @cindex erroneous data
319 @cindex errors, in data
320
321 Data from real sources is rarely error free.
322 @pspp{} has a number of procedures which can be used to help
323 identify data which might be incorrect.
324
325 The @cmd{DESCRIPTIVES} command (@pxref{DESCRIPTIVES}) is used to generate
326 simple linear statistics for a dataset.  It is also useful for
327 identifying potential problems in the data.
328 The example file @file{physiology.sav} contains a number of physiological
329 measurements of a sample of healthy adults selected at random.
330 However, the data entry clerk made a number of mistakes when entering
331 the data.
332 @ref{ex-descriptives} illustrates the use of @cmd{DESCRIPTIVES} to screen this
333 data and identify the erroneous values.
334
335 @float Example, ex-descriptives
336 @cartouche
337 @example
338 @prompt{PSPP>} get file='@value{example-dir}/physiology.sav'.
339 @prompt{PSPP>} descriptives sex, weight, height.
340 @end example
341
342 Output:
343 @psppoutput {tutorial2}
344 @end cartouche
345 @caption{Using the @cmd{DESCRIPTIVES} command to display simple
346 summary information about the data.
347 In this case, the results show unexpectedly low values in the Minimum
348 column, suggesting incorrect data entry.}
349 @end float
350
351 In the output of @ref{ex-descriptives},
352 the most interesting column is the minimum value.
353 The @exvar{weight} variable has a minimum value of less than zero,
354 which is clearly erroneous.
355 Similarly, the @exvar{height} variable's minimum value seems to be very low.
356 In fact, it is more than 5 standard deviations from the mean, and is a
357 seemingly bizarre height for an adult person.
358 We can examine the data in more detail with the @cmd{EXAMINE}
359 command (@pxref{EXAMINE}):
360
361 In @ref{ex1} you can see that the lowest value of @exvar{height} is
362 179 (which we suspect to be erroneous), but the second lowest is 1598
363 which
364 we know from the @cmd{DESCRIPTIVES} command
365 is within 1 standard deviation from the mean.
366 Similarly the @exvar{weight} variable has a lowest value which is
367 negative but a plausible value for the second lowest value.
368 This suggests that the two extreme values are outliers and probably
369 represent data entry errors.
370
371 @float Example, ex1
372 @cartouche
373 [@dots{} continue from @ref{ex-descriptives}]
374 @example
375 @prompt{PSPP>} examine height, weight /statistics=extreme(3).
376 @end example
377
378 Output:
379 @example
380                    Extreme Values
381 +-------------------------------+-----------+-----+
382 |                               |Case Number|Value|
383 +-------------------------------+-----------+-----+
384 |Height in millimeters Highest 1|         14| 1903|
385 |                              2|         15| 1884|
386 |                              3|         12| 1802|
387 |                      Lowest  1|         30|  179|
388 |                              2|         31| 1598|
389 |                              3|         28| 1601|
390 +-------------------------------+-----------+-----+
391 |Weight in kilograms   Highest 1|         13| 92.1|
392 |                              2|          5| 92.1|
393 |                              3|         17| 91.7|
394 |                      Lowest  1|         38|-55.6|
395 |                              2|         39| 54.5|
396 |                              3|         33| 55.4|
397 +-------------------------------+-----------+-----+
398 @end example
399 @end cartouche
400 @caption{Using the @cmd{EXAMINE} command to see the extremities of the data
401 for different variables.  Cases 30 and 38 seem to contain values
402 very much lower than the rest of the data.
403 They are possibly erroneous.}
404 @end float
405
406 @node Dealing with suspicious data
407 @subsection Dealing with suspicious data
408
409 @cindex SYSMIS
410 @cindex recoding data
411 If possible, suspect data should be checked and re-measured.
412 However, this may not always be feasible, in which case the researcher may
413 decide to disregard these values.
414 @pspp{} has a feature whereby data can assume the special value `SYSMIS', and
415 will be disregarded in future analysis. @xref{Missing Observations}.
416 You can set the two suspect values to the `SYSMIS' value using the @cmd{RECODE}
417 command.
418 @example
419 @pspp{}> recode height (179 = SYSMIS).
420 @pspp{}> recode weight (LOWEST THRU 0 = SYSMIS).
421 @end example
422 @noindent
423 The first command says that for any observation which has a
424 @exvar{height} value of 179, that value should be changed to the SYSMIS
425 value.
426 The second command says that any @exvar{weight} values of zero or less
427 should be changed to SYSMIS.
428 From now on, they will be ignored in analysis.
429 For detailed information about the @cmd{RECODE} command @pxref{RECODE}.
430
431 If you now re-run the @cmd{DESCRIPTIVES} or @cmd{EXAMINE} commands in
432 @ref{ex-descriptives} and @ref{ex1} you
433 will see a data summary with more plausible parameters.
434 You will also notice that the data summaries indicate the two missing values.
435
436 @node Inverting negatively coded variables
437 @subsection Inverting negatively coded variables
438
439 @cindex Likert scale
440 @cindex Inverting data
441 Data entry errors are not the only reason for wanting to recode data.
442 The sample file @file{hotel.sav} comprises data gathered from a
443 customer satisfaction survey of clients at a particular hotel.
444 In @ref{ex-reliability}, this file is loaded for analysis.
445 The line @code{display dictionary.} tells @pspp{} to display the
446 variables and associated data.
447 The output from this command has been omitted from the example for the sake of clarity, but
448 you will notice that each of the variables
449 @exvar{v1}, @exvar{v2} @dots{} @exvar{v5}  are measured on a 5 point Likert scale,
450 with 1 meaning ``Strongly disagree'' and 5 meaning ``Strongly agree''.
451 Whilst variables @exvar{v1}, @exvar{v2} and @exvar{v4} record responses
452 to a positively posed question, variables @exvar{v3} and @exvar{v5} are
453 responses to negatively worded questions.
454 In order to perform meaningful analysis, we need to recode the variables so
455 that they all measure in the same direction.
456 We could use the @cmd{RECODE} command, with syntax such as:
457 @example
458 recode v3 (1 = 5) (2 = 4) (4 = 2) (5 = 1).
459 @end example
460 @noindent
461 However an easier and more elegant way uses the @cmd{COMPUTE}
462 command (@pxref{COMPUTE}).
463 Since the variables are Likert variables in the range (1 @dots{} 5),
464 subtracting their value  from 6 has the effect of inverting them:
465 @example
466 compute @var{var} = 6 - @var{var}.
467 @end example
468 @noindent
469 @ref{ex-reliability} uses this technique to recode the variables
470 @exvar{v3} and @exvar{v5}.
471 After applying  @cmd{COMPUTE} for both variables,
472 all subsequent commands will use the inverted values.
473
474
475 @node Testing data consistency
476 @subsection Testing data consistency
477
478 @cindex reliability
479 @cindex consistency
480
481 A sensible check to perform on survey data is the calculation of
482 reliability.
483 This gives the statistician some confidence that the questionnaires have been
484 completed thoughtfully.
485 If you examine the labels of variables @exvar{v1},  @exvar{v3} and @exvar{v4},
486 you will notice that they ask very similar questions.
487 One would therefore expect the values of these variables (after recoding)
488 to closely follow one another, and we can test that with the @cmd{RELIABILITY}
489 command (@pxref{RELIABILITY}).
490 @ref{ex-reliability} shows a @pspp{} session where the user (after recoding
491 negatively scaled variables) requests reliability statistics for
492 @exvar{v1}, @exvar{v3} and @exvar{v4}.
493
494 @float Example, ex-reliability
495 @cartouche
496 @example
497 @prompt{PSPP>} get file='@value{example-dir}/hotel.sav'.
498 @prompt{PSPP>} display dictionary.
499 @prompt{PSPP>} * recode negatively worded questions.
500 @prompt{PSPP>} compute v3 = 6 - v3.
501 @prompt{PSPP>} compute v5 = 6 - v5.
502 @prompt{PSPP>} reliability v1, v3, v4.
503 @end example
504
505 Output (dictionary information omitted for clarity):
506 @psppoutput {tutorial4}
507 @end cartouche
508 @caption{Recoding negatively scaled variables, and testing for
509 reliability with the @cmd{RELIABILITY} command. The Cronbach Alpha
510 coefficient suggests a high degree of reliability among variables
511 @exvar{v1}, @exvar{v3} and @exvar{v4}.}
512 @end float
513
514 As a rule of thumb, many statisticians consider a value of Cronbach's Alpha of
515 0.7 or higher to indicate reliable data.
516 Here, the value is 0.81 so the data and the recoding that we performed
517 are vindicated.
518
519
520 @node Testing for normality
521 @subsection Testing for normality
522 @cindex normality, testing
523
524 Many statistical tests rely upon certain properties of the data.
525 One common property, upon which many linear tests depend, is that of
526 normality --- the data must have been drawn from a normal distribution.
527 It is necessary then to ensure normality before deciding upon the
528 test procedure to use.  One way to do this uses the @cmd{EXAMINE} command.
529
530 In @ref{normality}, a researcher was examining the failure rates
531 of equipment produced by an engineering company.
532 The file @file{repairs.sav} contains the mean time between
533 failures (@exvar{mtbf}) of some items of equipment subject to the study.
534 Before performing linear analysis on the data,
535 the researcher wanted to ascertain that the data is normally distributed.
536
537 A normal distribution has a skewness and kurtosis of zero.
538 Looking at the skewness of @exvar{mtbf} in @ref{normality} it is clear
539 that the mtbf figures have a lot of positive skew and are therefore
540 not drawn from a normally distributed variable.
541 Positive skew can often be compensated for by applying a logarithmic
542 transformation.
543 This is done with the @cmd{COMPUTE} command in the line
544 @example
545 compute mtbf_ln = ln (mtbf).
546 @end example
547 @noindent
548 Rather than redefining the existing variable, this use of @cmd{COMPUTE}
549 defines a new variable @exvar{mtbf_ln} which is
550 the natural logarithm of @exvar{mtbf}.
551 The final command in this example calls @cmd{EXAMINE} on this new variable,
552 and it can be seen from the results that both the skewness and
553 kurtosis for @exvar{mtbf_ln} are very close to zero.
554 This provides some confidence that the @exvar{mtbf_ln} variable is
555 normally distributed and thus safe for linear analysis.
556 In the event that no suitable transformation can be found,
557 then it would be worth considering
558 an appropriate non-parametric test instead of a linear one.
559 @xref{NPAR TESTS}, for information about non-parametric tests.
560
561 @float Example, normality
562 @cartouche
563 @example
564 @prompt{PSPP>} get file='@value{example-dir}/repairs.sav'.
565 @prompt{PSPP>} examine mtbf
566                 /statistics=descriptives.
567 @prompt{PSPP>} compute mtbf_ln = ln (mtbf).
568 @prompt{PSPP>} examine mtbf_ln
569                 /statistics=descriptives.
570 @end example
571
572 Output:
573 @psppoutput {tutorial5}
574 @end cartouche
575 @caption{Testing for normality using the @cmd{EXAMINE} command and applying
576 a logarithmic transformation.
577 The @exvar{mtbf} variable has a large positive skew and is therefore
578 unsuitable for linear statistical analysis.
579 However the transformed variable (@exvar{mtbf_ln}) is close to normal and
580 would appear to be more suitable.}
581 @end float
582
583
584 @node Hypothesis Testing
585 @section Hypothesis Testing
586
587 @cindex Hypothesis testing
588 @cindex p-value
589 @cindex null hypothesis
590
591 One of the most fundamental purposes of statistical analysis
592 is hypothesis testing.
593 Researchers commonly need to test hypotheses about a set of data.
594 For example, she might want to test whether one set of data comes from
595 the same distribution as another,
596 or
597 whether the mean of a dataset significantly differs from a particular
598 value.
599 This section presents just some of the possible tests that @pspp{} offers.
600
601 The researcher starts by making a @dfn{null hypothesis}.
602 Often this is a hypothesis which he suspects to be false.
603 For example, if he suspects that @var{A} is greater than @var{B} he will
604 state the null hypothesis as @math{ @var{A} = @var{B}}.@c
605 @footnote{This example assumes that it is already proven that @var{B} is
606 not greater than @var{A}.}
607
608 The @dfn{p-value} is a recurring concept in hypothesis testing.
609 It is the highest acceptable probability that the evidence implying a
610 null hypothesis is false, could have been obtained when the null
611 hypothesis is in fact true.
612 Note that this is not the same as ``the probability of making an
613 error'' nor is it the same as ``the probability of rejecting a
614 hypothesis when it is true''.
615
616
617
618 @menu
619 * Testing for differences of means::
620 * Linear Regression::
621 @end menu
622
623 @node Testing for differences of means
624 @subsection Testing for differences of means
625
626 @cindex T-test
627 @vindex T-TEST
628
629 A common statistical test involves hypotheses about means.
630 The @cmd{T-TEST} command is used to find out whether or not two separate
631 subsets have the same mean.
632
633 @ref{ex-t-test} uses the file @file{physiology.sav} previously
634 encountered.
635 A researcher suspected that the heights and core body
636 temperature of persons might be different depending upon their sex.
637 To investigate this, he posed two null hypotheses:
638 @itemize @bullet
639 @item The mean heights of males and females in the population are equal.
640 @item The mean body temperature of males and
641       females in the population are equal.
642 @end itemize
643 @noindent
644 For the purposes of the investigation the researcher
645 decided to use a  p-value of 0.05.
646
647 In addition to the T-test, the @cmd{T-TEST} command also performs the
648 Levene test for equal variances.
649 If the variances are equal, then a more powerful form of the T-test can be used.
650 However if it is unsafe to assume equal variances,
651 then an alternative calculation is necessary.
652 @pspp{} performs both calculations.
653
654 For the @exvar{height} variable, the output shows the significance of the
655 Levene test to be 0.33 which means there is a
656 33% probability that the
657 Levene test produces this outcome when the variances are equal.
658 Had the significance been less than 0.05, then it would have been unsafe to assume that
659 the variances were equal.
660 However, because the value is higher than 0.05 the homogeneity of variances assumption
661 is safe and the ``Equal Variances'' row (the more powerful test) can be used.
662 Examining this row, the two tailed significance for the @exvar{height} t-test
663 is less than 0.05, so it is safe to reject the null hypothesis and conclude
664 that the mean heights of males and females are unequal.
665
666 For the @exvar{temperature} variable, the significance of the Levene test
667 is 0.58 so again, it is safe to use the row for equal variances.
668 The equal variances row indicates that the two tailed significance for
669 @exvar{temperature} is 0.20.  Since this is greater than 0.05 we must reject
670 the null hypothesis and conclude that there is insufficient evidence to
671 suggest that the body temperature of male and female persons are different.
672
673 @float Example, ex-t-test
674 @cartouche
675 @example
676 @prompt{PSPP>} get file='@value{example-dir}/physiology.sav'.
677 @prompt{PSPP>} recode height (179 = SYSMIS).
678 @prompt{PSPP>} t-test group=sex(0,1) /variables = height temperature.
679 @end example
680 Output:
681 @psppoutput {tutorial6}
682 @end cartouche
683 @caption{The @cmd{T-TEST} command tests for differences of means.
684 Here, the @exvar{height} variable's two tailed significance is less than
685 0.05, so the null hypothesis can be rejected.
686 Thus, the evidence suggests there is a difference between the heights of
687 male and female persons.
688 However the significance of the test for the @exvar{temperature}
689 variable is greater than 0.05 so the null hypothesis cannot be
690 rejected, and there is insufficient evidence to suggest a difference
691 in body temperature.}
692 @end float
693
694 @node Linear Regression
695 @subsection Linear Regression
696 @cindex linear regression
697 @vindex REGRESSION
698
699 Linear regression is a technique used to investigate if and how a variable
700 is linearly related to others.
701 If a variable is found to be linearly related, then this can be used to
702 predict future values of that variable.
703
704 In example @ref{ex-regression}, the service department of the company wanted to
705 be able to predict the time to repair equipment, in order to improve
706 the accuracy of their quotations.
707 It was suggested that the time to repair might be related to the time
708 between failures and the duty cycle of the equipment.
709 The p-value of 0.1 was chosen for this investigation.
710 In order to investigate this hypothesis, the @cmd{REGRESSION} command
711 was used.
712 This command not only tests if the variables are related, but also
713 identifies the potential linear relationship. @xref{REGRESSION}.
714
715
716 @float Example, ex-regression
717 @cartouche
718 @example
719 @prompt{PSPP>} get file='@value{example-dir}/repairs.sav'.
720 @prompt{PSPP>} regression /variables = mtbf duty_cycle /dependent = mttr.
721 @prompt{PSPP>} regression /variables = mtbf /dependent = mttr.
722 @end example
723 Output (excerpts):
724 @psppoutput {tutorial7b}
725 @end cartouche
726 @caption{Linear regression analysis to find a predictor for
727 @exvar{mttr}.
728 The first attempt, including @exvar{duty_cycle}, produces some
729 unacceptable high significance values.
730 However the second attempt, which excludes @exvar{duty_cycle}, produces
731 significance values no higher than 0.06.
732 This suggests that @exvar{mtbf} alone may be a suitable predictor
733 for @exvar{mttr}.}
734 @end float
735
736 The coefficients in the first table suggest that the formula
737 @math{@var{mttr} = 9.81 + 3.1 \times @var{mtbf} + 1.09 \times @var{duty_cycle}}
738 can be used to predict the time to repair.
739 However, the significance value for the @var{duty_cycle} coefficient
740 is very high, which would make this an unsafe predictor.
741 For this reason, the test was repeated, but omitting the
742 @exvar{duty_cycle} variable.
743 This time, the significance of all coefficients no higher than 0.06,
744 suggesting that at the 0.06 level, the formula
745 @math{@var{mttr} = 10.5 + 3.11 \times @var{mtbf}} is a reliable
746 predictor of the time to repair.
747
748
749 @c  LocalWords:  PSPP dir itemize noindent var cindex dfn cartouche samp xref
750 @c  LocalWords:  pxref ie sav Std Dev kilograms SYSMIS sansserif pre pspp emph
751 @c  LocalWords:  Likert Cronbach's Cronbach mtbf npplot ln myfile cmd NPAR Sig
752 @c  LocalWords:  vindex Levene Levene's df Diff clicksequence mydata dat ascii
753 @c  LocalWords:  mttr outfile