This week we’ll take a quick tour of the classic T-tests, ANOVAs, and GLMs in SPSS. The dataset we will use will match up with the one that was used in the SAS workshop. Please download and open this Excel file into SPSS. This data is fictional and contains 4 variables:
- Field: A nominal piece of information indicating what field the data was collected in
- Block: A nominal piece of information indicating which block the data was collected in
- Trmt: Treatment – a nominal piece of data indicating which treatment was applied
- Nitrogen: A continuous or scale piece of data indicating the amount of N expressed in the sample taken
This trial was designed as a Random Complete Block Design and should be analyzed as such. However, to showcase the t-test in SPSS we will take a step back and play with the data to start.
T-test
SPSS makes it easy for us to conduct t-tests on our data. If you go to file menu Analyze -> Compare Means you will see 3 different types of t-tests available to you. You should be comfortable with each one in order to be able to choose the correct one for your analysis.
Quick review of the different t-tests and examples of each
One sample t-test: This test will compare the mean of your data to 1 value. Examples of this may be – you have collected %protein data on a number of different brands of adult dog food. The recommended %protein in adult dog feed is 25% and you want to check whether your samples are equal to the recommended amount. For this type of test you would use a One-sample t-test.
Independent Samples t-test: This test allows you to compare 2 means from 2 independent groups. Examples: Average age between males and females.
Paired-Samples t-test: This test allows you to compare 2 means taken on the same experimental units. Examples: Average weight before a treatment and average weight after a treatment on the same 20 experimental units.
These 3 tests are used primarily when the outcome variable you are testing is continuous or scale. There are similar t-test equivalents for outcome variables that may not follow that normal distribution. These are:
- Independents samples: Mann-Whitney, Kolmogorov-Smirnov Z
- Paired_samples: Wilcoxon, Sign, McNemar
Independents samples t-test
With our sample data – we have a variable called Field. We want to see whether there are any differences between the 2 fields where the data was collected. Please note – that we would NOT do this for our trials, we are only doing this for the purposes of this workshop. Ideally we would have a separate dataset that would be more appropriate, but in the interest of efficiency, I have chosen to use the same dataset and create a fictitious variable for demonstration purposes only.!!!
To conduct the Independent Samples t-test:
- Analyze
- Compare Means
- Independent Samples T Test
- Select Nitrogen as the Test variable and Field as the Grouping Variable
Notice that the Grouping Variable has ?, ? – you need to tell SPSS what the values for Field are. Click on Define Groups and set 1 as Group1 and 2 as Group2. Note that you would put in the values that are represented in your dataset – ours just happen to be “1” and “2” - Continue
- OK
- Compare Means
In the output window you should now see 2 tables. The first one displays the mean, standard deviation, and standard error for the Nitrogen variable for each group – so each Field.
The second table provides the t-test results. Note that the first half of this table contains the Levene’s test for equality of variances. One of the assumptions of a t-test, is that the variation of your outcome variance in both groups is equal. Lucky for us, SPSS provides us with t-test results for the situation where we have equal variances and when we do not have equal variances. In our case, the Levene’s test tells us that we have equal variation between our groups – p= 0.840 which means we accept our Null hypothesis that the variation between our groups is equal. We also see that there are indeed differences in Nitrogen between our 2 fields = < 0.0001 – note that the output says p= 0.000 because it only shows the first 3 digits. P is NEVER = 0!!
One-way ANOVA
Now let’s assume that we conducted a Completely Randomized Design (CRD) where we randomly selected our experimental units and placed 4 onto each of the 6 treatments. If this was our experimental design then we would conduct a One-way ANOVA. There are 2 ways to do this in SPSS. Here is the first method:
- Analyze
- Compare Means
- One-way ANOVA
- Select Nitrogen as your Dependent Variable and Treatment as your Factor
- OK
- Compare Means
Your output window should provide with the matching ANOVA table. In our example here, the Between Groups is non-significant with a p-value=0.959. The table shows us our Within Group SS, df, and MS.
The second method:
- Analyze
- General Linear Model
- Univariate
- Select Nitrogen as your Dependent Variable and Treatment as your Fixed Factor
- OK
- General Linear Model
Your output window will now provide you with 2 tables. The first is a Between-Subjects Factor table – showing you where your observations are in relation to the fixed effect of treatment. In our example we can confirm that we have 4 observations (experimental units) on each of the 6 treatments. This is a great way of checking that SPSS has read your data correctly.
Your second table is the ANOVA table – labelled Tests of Between-Subjects Effects. Notice that the 1st ANOVA table you saw above matches this one, but it provides more information. The Intercept – which is the overall mean. The same conclusions are drawn from this table than the One-way ANOVA table. I would recommend that you perform any ANOVAs using this method.
General Linear Model
So we know that our data was collected by implementing an RCBD, and we have a variable called Block in our dataset that is a RANDOM effect. How do we implement this aspect in SPSS?
The proper statistical model is:
To do this in SPSS:
- Analyze
- General Linear Model
- Univariate (because we only have 1 outcome variable we are working with)
- Select Nitrogen as your Dependent Variable and Treatment as your Fixed Factor
- Now we will add our Block variable as our Random Factor
- Model
- Notice that by default SPSS is using a Full Factorial model. As a basic RCBD we only want the main effects of Treatment and Block included in our model
- Select Custom at the top. Then select both Trmt and Block – Select Main Effects in the Build Term(s) dropdown menu and click the arrow to place the 2 main effects in the Model: box
- Continue
- OK
- General Linear Model
In our output window you should now see 3 tables. The first one – Between Subjects Factor, lists the Treatments and the Blocks. Note that you have 6 observations in each block.
The second table presents our Tests of Between-Subjects Effects or our ANOVA table. Notice that each factor in our model lists the Hypothesis and the Error. This is because of our model. In our model – the error term has been corrected for the 2 effects in our model. Note that the p-value for Treatment is different from our fixed effects model p=0.787 – the model now incorporates our random Block factor – so it has adjusted or accounted for the variation due to Block before looking at the Treatment differences.
PostHoc tests
In our example, our treatments were not significant, therefore the means among our 4 treatments did not differ – no need to run any PostHoc or means comparisons tests. However, you should know how to run these in case you research data shows otherwise. To conduct PostHoc tests, we will do these on our Treatments for demonstration purposes, select the following :
Analyze
- General Linear Model
- Univariate (because we only have 1 outcome variable we are working with)
- Select Nitrogen as your Dependent Variable and Treatment as your Fixed Factor
- Now we will add our Block variable as our Random Factor
- Model
- Notice that by default SPSS is using a Full Factorial model. As a basic RCBD we only want the main effects of Treatment and Block included in our model
- Select Custom at the top. Then select both Trmt and Block – Select Main Effects in the Build Term(s) dropdown menu and click the arrow to place the 2 main effects in the Model: box
- PostHoc
- Select the Trmt Factor from the left hand box and add to the PostHoc Tests for box. Once you do this the tests in the bottom half of this dialogue box become available.
- Select Tukey
- Continue
- Model
- OK
You will now have 2 additional tables in your output. The first one shows you each pairwise combination of treatments along with a difference, a standard error for the difference, a p-value, and 95% confidence limits for the difference. The bottom table summarizes this table.
NOTE: if you only have 2 levels in your treatment or fixed effect factor, SPSS will NOT run the PostHoc tests. It’s telling you that if the ANOVA says they’re different – then it doesn’t have to run the extra test because you already know the answer.
Conclusion
This workshop reviewed the use of t-tests, one-way ANOVA, and a GLM in SPSS. As an FYI, there is a lot of talk about GLIMMIX in the SAS side of the house and SPSS can do similar analyses – I will propose a workshop in the upcoming Summer session that will showcase GLMMs in SPSS.
Remember your research question when conducting any analysis and match the analysis to your research question – always!!
2 thoughts on “ARCHIVE: W18 SPSS Workshop: T-tests, ANOVAs, and GLMs”