1
$\begingroup$

I'm going to paste up a sample dataset so that everyone can see it if necessary (I can't post my own data for ethical reasons). The data are called Survey.sav and can be downloaded via the survey.zip file here. Displaying the data:

 id   toptim sex age

415       22   2  24
  9       19   1  39
425       19   2  48
307       26   1  41
440       18   1  23
484       17   2  31
341       10   2  30
300       25   1  23
 61       13   2  18
 24        9   1  23
138       30   1  27
184       28   2  34
183       16   1  35
144       20   2  43
 57       17   1  50
491       14   1  57
 41       19   2  37
  6       21   2  41
157       17   2  19
287       26   2  25
 53       14   1  23
330       13   2  53
379       25   2  47
 59       14   2  36
416       21   1  21
508       24   2  26
116       20   2  48
422       26   2  24
 87       21   1  25
434       12   2  47
264       29   1  18
442        9   2  24
540       22   1  36
470       27   2  49
252       26   2  21
338       16   2  45
517       19   1  18
179       16   2  45
420       21   1  69
 66        .   1  59
  7       28   1  33
404       28   2  24
331       10   1  22
336       18   2  43
  5       30   2  48
291       19   2  30
 79       17   2  46
342       19   1  24
219       26   1  63
 85       14   2  20
 11       10   2  22
494       21   2  21
127       27   2  37
359       10   2  39
459       24   1  32
301       24   1  54
 31       18   2  27
233       21   2  21
159       30   2  65
139       23   2  32
 20       18   2  42
533       19   1  38
236       19   2  26
154       28   2  52
477       15   2  36
495       26   2  60
344       10   2  33
132       20   1  54
119       30   2  68
340       26   2  66
258       28   2  24
439       27   2  38
 22       24   2  57
458       18   1  50
541       22   1  50
370       17   2  24
362       20   2  46
180       30   2  70
345       18   2  30
229       21   2  21
507        8   2  46
546       27   1  58
133       23   2  23
263       16   1  49
530       23   2  25
109       26   1  33
337       18   1  32
509       24   1  42
235       21   1  26
498       26   2  25
304       23   2  36
437       24   1  24
403       27   2  56
311       24   1  40
499       26   1  36
103       23   2  23
 14       23   1  26
316       26   2  60
 28       20   1  27
209       25   1  70
535       24   2  46
518       23   2  39
377       25   2  55
254       27   1  33
369       18   2  38
231       17   1  26
315       24   2  31
489       20   1  27
438       24   2  35
419       22   1  44
313       28   2  46
538       28   2  28
295       26   2  37
120       26   2  74
368       27   2  82
161       21   1  43
456       21   2  24
 40       20   1  36
 60       27   1  45
290       19   1  50
367       16   1  27
467       26   1  21
 32       16   1  31
217       30   2  49
 58       17   1  49
497       20   2  48
453       24   2  20
485       23   1  25
303       29   2  58
216       29   1  31
188       28   2  29
162       20   1  22
 67       15   2  20
478       23   1  21
228       25   2  26
107       16   1  39
177       17   2  24
 27       28   2  38
176       26   2  53
351       15   2  31
143       26   1  21
317       23   2  53
178       21   2  42
421       26   2  68
701       17   1  47
504       24   1  48
329       14   1  18
128       19   2  39
309       27   1  57
406       20   1  34
134       28   2  41
 70       15   2  30
 63       16   2  19
372       17   1  26
181       29   1  46
158       27   2  58
192       29   2  44
227       21   2  30
312       25   1  21
 36       23   2  22
126       25   2  35
326       28   1  46
163       29   2  22
452       22   2  27
 81       18   2  20
455       23   2  42
 78       24   2  25
332       26   2  31
506       20   2  60
 39       22   2  24
156       22   2  36
206       24   1  36
428       17   2  24
466       23   1  47
435       20   2  34
259       20   1  54
405       23   1  20
266       23   1  55
454       22   1  30
354       21   2  41
193       29   2  23
376       20   1  22
700       19   2  44
519       23   2  21
131       19   2  23
201       24   1  66
534       20   1  39
510       16   2  50
457       22   1  51
411       23   2  49
104       24   2  51
115       26   2  38
129       15   1  50
153       27   1  49
318       24   2  25
 93       16   1  47
185       22   2  36
365       20   2  52
378       21   1  25
500       15   1  22
282       30   2  51
451       19   1  42
 95       24   2  41
302       21   1  43
113       24   2  35
205       16   2  28
545       21   2  28
493       25   2  28
488       23   1  41
483       19   1  40
423       25   2  27
321       23   1  23
 13       30   2  45
410       27   2  48
286       28   1  33
208       21   2  27
490       30   2  22
164       17   1  31
 82       16   2  49
293       24   1  34
292       19   2  33
536       26   2  24
214       20   1  56
402       23   2  23
 56       21   2  48
105       20   1  48
101       25   2  25
246       20   1  65
111       23   1  32
 83       18   2  42
191       28   2  49
486       22   1  24
 94       23   2  21
 89       28   1  22
211       22   1  33
 42       27   1  50
515       27   2  26
251       26   1  45
516       19   1  40
476       30   2  61
 86       20   1  22
110       20   2  27
 80       30   2  22
433       26   2  49
220       29   1  36
409       20   1  46
537       21   2  27
529       15   2  41
461       10   2  21
464       25   1  36
357       22   1  36
 44       25   1  40
204       24   1  35
117       23   1  54
 62       22   1  22
358       23   2  28
429       22   1  25
106       18   1  37
503       18   2  63
353       21   2  48
 29       27   1  21
364       18   1  56
335       26   1  36
355       20   2  37
 84       20   1  37
102       23   2  26
238       30   2  41
135       24   2  49
112       25   2  50
374       21   1  35
469       22   2  55
375       18   1  30
531       26   1  26
256       27   1  48
 52       26   1  51
308        7   2  22
463       20   1  19
265       21   1  30
401       24   2  28
 33       29   1  52
142       24   1  23
443       17   2  25
501       29   2  62
363       23   2  35
262       28   2  36
468       26   2  45
462       26   2  44
 30       24   1  37
296       29   2  24
532       27   2  56
417       24   1  31
186       18   2  44
 15       22   1  51
  1       19   1  45
356       27   1  50
427       19   1  50
 55       21   2  19
436       18   2  60
 38       24   1  56
492       17   1  35
130       14   1  33
237       23   1  32
339       25   1  41
 76       25   1  22
 65       24   2  46
502       23   1  28
310       22   1  33
371       22   2  75
118       24   2  36
207       27   1  36
 17       23   1  33
255       24   2  44
 77       21   1  23
240       22   2  44
108       19   2  40
 12       24   2  31
407       23   2  26
285       16   2  21
702       28   1  46
289       21   2  32
230       24   1  20
511       24   1  21
496       23   1  31
212       25   2  35
542       21   1  26
190       21   2  23
481       25   2  39
189       16   1  46
 23       25   2  60
182       24   1  42
210       26   2  35
418       17   2  22
432       22   2  44
165       17   1  46
430       19   2  29
 68       24   1  55
  2       19   2  21
141       28   2  41
513       26   1  67
479       22   2  53
257       22   2  56
242       21   2  18
234       26   2  44
 91       27   1  51
 34       25   1  64
  8       21   2  38
412       25   1  48
 64       26   1  27
327       17   2  46
226       20   2  48
284       28   2  55
280       26   1  34
528       15   1  27
424       18   2  63
544       22   2  23
137       20   2  22
241       27   2  48
213       27   1  22
373       25   1  32
260       19   2  41
380       24   1  38
480       25   1  29
514       21   2  62
203       26   2  41
152       19   2  31
294       20   1  41
414       19   1  24
361       23   1  48
413       24   1  27
 18       27   2  61
 26       27   2  55
 54       29   2  37
136       21   1  22
  4       24   2  47
276       29   1  42
244       21   1  47
114       21   2  50
366       26   1  19
 43       27   1  37
 16       22   2  37
460       27   2  35
505       16   2  33
232       17   2  22
482       19   2  20
512       22   2  18
218       30   2  31
319       18   1  44
151       24   1  40
 92       21   2  45
278       26   2  36
487       17   2  31
333       23   1  32
279       20   2  50
  3       23   2  42
195       23   2  29
187       19   1  31
261       24   2  27
431       21   1  31
281       27   2  78
 51       21   2  27
526       17   2  28
194       27   1  42
543       18   2  42
352       23   2  34
283       27   2  21
 19       22   2  33
305       25   2  28
 69       20   2  23
328       20   2  21
140       21   2  38
288       19   2  21
160       24   1  22
539       22   1  28
 21       21   2  45
 37       18   1  23
215       17   2  23
465       20   2  25
297       27   2  35
306       20   1  21
239       18   2  40
314       29   2  35
 88       14   1  26
343       18   1  48
242       22   1  54
441       24   2  36
253       21   2  48
 35       18   2  35
 10       23   2  67
527       23   2  47
202       22   2  21
 90       21   1  24
408       20   1  32
360       18   1  50
155        .   2  29
277       22   2  34
520        .   2  52
 25       28   2  48
426        .   2  21
245       23   2  74

To try to mimic what I'm doing in my own data, I've run a general linear model analysis in SPSS with one continuous dependent variable (in this sample dataset I have used "Total Optimism" as a representative variable), one categorical independent variable ("sex" from the sample dataset) and one continuous independent variable ("age" from the sample dataset, along with the interaction between these two independent variables.

The output table I get is below:enter image description here

If I then run the same analysis via the regression option in SPSS (I created the interaction term by multiplying the two independent variables together via compute to create the new interaction variable) I get the below output:enter image description here

My confusion is that the outputs are different (in the general linear model output the interaction term is not significant, whilst in the regression output it is marginally significant. FYI in my own data I have the opposite effect - my interaction term is highly significant in the general linear model output and not significant at all in the regression output).

Can anyone help me understand these differences? Could it be something to do with the contrasts used? Strangely, if I run both the same analyses in R (via lm and via Anova in the car package specifying same sums of squares as in SPSS) both R outputs are the same and equivalent to the regression output in SPSS (but not the general linear model output).

Can anyone shed some light on this for me? And also help me interpret the outputs? Thank you very much in advance and please let me know if I can edit this question to include more information!

$\endgroup$

closed as off-topic by Carl, Michael Chernick, Stephan Kolassa, kjetil b halvorsen, mdewey Mar 3 '18 at 13:27

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Carl, Michael Chernick, Stephan Kolassa, kjetil b halvorsen, mdewey
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Despite saying you input age in GLM as continuous variable, you actually input it as a factor. Hence df=55. This what Martijn correctly noticed. $\endgroup$ – ttnphns Mar 2 '18 at 13:31
  • $\begingroup$ Thank you @ttnphns - after reading Martin's comments I understand now. I now feel very silly! But at least I know what my mistake was :) $\endgroup$ – Sarah Mar 2 '18 at 13:33
  • 1
    $\begingroup$ Put age in Covariates field, go to Model button and select custom model with both main effects and the factor-covariate interaction $\endgroup$ – ttnphns Mar 2 '18 at 13:35
2
$\begingroup$

I am not sure whether this solves everything, but after a quick look, I guess that your age variable in the SPSS GLM model was treated as a categorical variable (it has df 55 instead of 1). (this could explain why the model matches a higher degree of variance 2155 instead of 405)

$\endgroup$
  • $\begingroup$ Thank you so much for your answer! This makes sense - how stupid of me. I was putting age into fixed factors along with sex because I wanted to include the interaction between the two, but it seems like SPSS then treats my continuous variable as categorical (I assumed it would treat it as continuous as it was specified as a scale variable). Is there anyway to specify continuous by categorical interactions in the General Linear Model option in SPSS, or can you only do this via the regression option? Thank you so very much again!!! $\endgroup$ – Sarah Mar 2 '18 at 13:17
  • 2
    $\begingroup$ It should be possible. But I don't know SPSS to tell you how to do it. In the worst case, if you can not find the option, you can generate your own interaction term by making an extra variable like you did in R. In the end it is all just the same type of linear matrix equation and the options that we have in the software is all front-end stuff. $\endgroup$ – Martijn Weterings Mar 2 '18 at 13:27
  • 1
    $\begingroup$ Ah yes, that works! So if I add the categorical "sex" variable to fixed factors and then the continuous "age" variable to covariates, along with my generated interaction term, it gives me the same output as the regression option with the correct degrees of freedom for age (1). I feel very silly now! Thank you so much for clarifying this for me :) $\endgroup$ – Sarah Mar 2 '18 at 13:31
  • 2
    $\begingroup$ I might just stick to R in future to be honest, haha! $\endgroup$ – Sarah Mar 2 '18 at 13:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.