supplementary material Appendix I - SPSS instructions

61 downloads 8795 Views 798KB Size Report
Feb 25, 2013 - SPSS. Step 1: Normality tests go to Analyze – Descriptive Statistics ... Alternatively data may be transformed using the Box-Cox procedure ...... as is done in MINITAB and SPSS, the “car” package must be installed and.
SPSS Step 1: Normality tests go to Analyze – Descriptive Statistics Explore from the drop down list. In the box that opens enter the column identifier for the data that you wish to test in the Dependent List box. Click on Plots and tick the Normality plots with tests option. Click Continue then click Ok. The relevant output for this test can be found in the following table:

Tests of Normality Kolmogorov-Smirnova Statistic Metabolism

.140

Df

Shapiro-Wilk Sig.

15

.200

Statistic *

.957

df

Sig. 15

.633

a. Lilliefors Significance Correction *. This is a lower bound of the true significance.

The significance of the test is indicated by the p value in the table. If the p value is less than 0.05 then the distribution of data differs significantly from normal. If it is > .05 then the data can be considered normally distributed. A normality plot will also be shown called Normal Q-Q Plot of ‘column identifier’.

EXAMINE VARIABLES=Metabolism /PLOT BOXPLOT STEMLEAF NPPLOT /COMPARE GROUPS /STATISTICS DESCRIPTIVES /CINTERVAL 95

/MISSING LISTWISE /NOTOTAL.

Step 3: Attempt to normalise the distribution by transforming it. Data can be easily transformed by using the Transform – Compute Variable command. Enter a name for your new variable in the Target Variable box and enter your transformation in the Numeric Expression box (e.g., LG10(Variable name)). SPSS will create a new column with the transformed variable. COMPUTE LOGMetabolism=LG10(Metabolism). EXECUTE.

Alternatively data may be transformed using the Box-Cox procedure Go to Transform – Prepare Data for Modelling Automatic from the drop down list. In the Fields tab you can specify which variables to transform by moving them to the Inputs box. In the Settings tab click on Rescale Fields. Tick the box before ‘Rescale a continuous target with a Box-Cox transformation to reduce skew’. Click Run. This will create a new column with the transformed variable.

Step 7: Paired comparisons of parametric normally distributed data For two sample t-test Go to Analyze – Compare Means Independent Samples T-Test from the drop down list. This will open a new window. Data should be organized as shown in Table 1. Add the variable to be tested in the Test Variable(s) box. You can enter multiple variables (e.g., metabolism and body mass) if you want. Identify which data belong to which treatment by entering your treatment column into the Grouping Variable box. You now need to define your treatment groups by clicking the Define Groups button. A new window will pop up. When using numeric treatment groups enter the values for Group 1 and Group 2 (i.e., 1 and 2 respectively in our example in Table 1). If you have used string codes you need to identify the codes between apostrophe’s, e.g., for control = C and treatment =T, enter “C” for Group 1 and “T” for Group 2. Click Continue. Click Ok. The output appears as follows. Group Statistics Treatment Metabolism

N

Mean

Std. Deviation

Std. Error Mean

1.00

10

1.5380

.19510

.06169

2.00

5

.9760

.20403

.09125

Independent Samples Test Levene's Test for Equality of Variances

t-test for Equality of Means 95% Confidence Interval

Sig.

Metabolism

Equal

df

(2-

Mean

Std. Error

tailed)

Difference

Difference

of the Difference

F

Sig.

t

Lower

Upper

.348

.565

5.185

13

.000

.56200

.10839

.32784

.79616

5.102

7.771

.001

.56200

.11015

.30670

.81730

variances assumed Equal variances not assumed

The first table summarizes your data and gives sample sizes, Mean, SD and SEM. The second table gives the results for the t-test. A t-test assumes equal variances and the first two columns in the table show the results for Levene’s test for equality of variances. If p>0.05 variances are equal and you will use the top row. The next 3 columns give the results for the independent t-test (tvalue, degrees of freedom and p-value respectively). In this case p|z|) Metabolism2 - Metabolism1 == 0 0.12000 0.04380 2.740 0.017 * Metabolism3 - Metabolism1 == 0 0.05133 0.04380 1.172 0.470 Metabolism3 - Metabolism2 == 0 -0.06867 0.04380 -1.568 0.260 --Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Adjusted p values reported -- single-step method)

The Levels that are being compared are given in the left-most column. Based on the p-values (Pr(>|z|) column), Metabolism2 differed significantly from Metabolism1 (P = 0.017), but none of the other Levels differed significantly from each other (P > .05).

Step 11 Power analysis To perform power analyses, the “pwr” package must be installed using the install.packages() function. To use the functions in the “pwr” package, it must be loaded using the library() function. To perform a power analysis on a two sample t-test using the pwr.t2n.test() function, you need to input the sample sizes of the two samples (i.e. n1 = 10, and n2 = 10; note that the default significance level is set to 0.05). To specify the effect size in R, the % difference that you would consider important to detect needs to be divided by the standard deviation; thus, using the same mean, % difference, and standard deviation as in the MINITAB example: d = 1.368 * 0.05 / 0.133.

install.packages("pwr") library(pwr) pwr.t2n.test(n1 = 10, n2 = 10, d = 1.368 * 0.05 / 0.133) t test power calculation n1 n2 d sig.level power alternative

= = = = = =

10 10 0.5142857 0.05 0.1931212 two.sided

As outlined in the MINITAB example, the pwr.t.test() function can be used to calculate the sample sizes required to obtain a specified level of power (e.g. power = 0.8).

pwr.t.test(power = 0.8, d = 1.368 * 0.05 / 0.133, type = "two.sample") Two-sample t test power calculation n d sig.level power alternative

= = = = =

60.32651 0.5142857 0.05 0.8 two.sided

NOTE: n is number in *each* group

Step 13 : Two-way ANOVA Two-way ANOVA This analysis uses the data in Table 1. In order to use Type III sums-of-squares as is done in MINITAB and SPSS, the “car” package must be installed and loaded using the library() function. Two-way ANOVAs can be analyzed using the aov() function. The aov() function is nested within the Anova() function specifying that we want the analysis to use type III sums-of-squares (i.e. type = “III”). R offers a number of different ways by which factor levels can be compared (i.e. contrasted in statistical terms). Treatment contrasts are the default method in R; however, this type of contrasts is not valid for two-way ANOVAs using type III sums-of-squares. Helmert or sum contrasts are two types of contrasts that are valid for this type of ANOVA. Sum contrasts are used in the command below by specifying "contr.sum" in the function options(contrasts()). The Anova() function will output F-value, p-values, and the other values that are used to calculate them. In this example, the

Levels:Sex interaction was non-significant (F2,9 = 1.3, P = 0.32), and thus it can be removed from the model. The model without the interaction suggests that there is a strong effect of Levels (F2,11 = 39.5, P < 0.0001), but that the effect of Sex is non-significant (F1,11 = 1.96, P = 0.19). install.packages(“car”) library(car) options(contrasts=c("contr.sum", "contr.poly")) Anova(aov(Metabolism ~ Levels + Sex + Levels:Sex, data = Table1), type = "III") Anova Table (Type III tests) Response: Metabolism Sum Sq Df F value Pr(>F) (Intercept) 26.6451 1 1654.4056 1.634e-11 *** Levels 1.2104 2 37.5774 4.278e-05 *** Sex 0.0333 1 2.0648 0.1846 Levels:Sex 0.0419 2 1.3000 0.3192 Residuals 0.1450 9 --Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Anova(aov(Metabolism ~ Levels + Sex, data = Table1), type = "III") Anova Table (Type III tests) Response: Metabolism Sum Sq Df F value Pr(>F) (Intercept) 26.6451 1 1568.824 3.221e-13 *** Levels 1.3418 2 39.502 9.533e-06 *** Sex 0.0333 1 1.958 0.1893 Residuals 0.1868 11 --Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Repeated-measures two-way ANOVA This analysis examines the effect of Levels and Sex on Metabolism including a random factor of ID. This analysis can be performed using either the lme() or the aov() functions; however, only the commands for the aov() function will be shown. The random effect of ID is included in the aov() function it is included by adding “+ Error(ID)” in the formula. For this analysis, the data in Table 2 needs to be in ‘stacked format’. The “Levels * Sex” notation suggests that both the main effects of Levels and Sex are tested in addition to their interaction. The “Levels * Sex” interaction was not significant (F2,26 = 0.06, P = 0.94), and thus, it was removed from the model. There was a significant in Metabolism among the Levels (F2,28 = 3.78, P = 0.04); however, Sex did not significantly affect Metabolism (F1,13 = 0.33, P = 0.58).

summary(aov(Metabolism ~ Levels * Sex + Error(ID), data = Table2stack)) Error: ID Df Sum Sq Mean Sq F value Pr(>F) Sex 1 0.06848 0.068481 0.3256 0.578 Residuals 13 2.73383 0.210295 Error: Within Df Sum Sq Mean Sq F value Pr(>F) Levels 2 0.10875 0.054376 3.5258 0.04417 * Levels:Sex 2 0.00193 0.000967 0.0627 0.93936 Residuals 26 0.40098 0.015422 --Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

summary(aov(Metabolism ~ Levels + Sex + Error(ID), data = Table2stack)) Error: ID Df Sum Sq Mean Sq F value Pr(>F) Sex 1 0.06848 0.068481 0.3256 0.578 Residuals 13 2.73383 0.210295 Error: Within Df Sum Sq Mean Sq F value Pr(>F) Levels 2 0.10875 0.054376 3.7787 0.03525 * Residuals 28 0.40292 0.014390 --Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Step 14: Proceed in the same way as for step 13 for Two-way ANOVA, but with additional factors added to the model formula

Step 18:

non parametric tests paired comparisons

Mann-Whitney U/ two-sample Wilcoxon test This analysis compares Metabolism between the two Treatments in Table 1. The Mann-Whitney U test can also be called a two-sample Wilcoxon test. To determine the median of each Treatment, use the tapply() function.

tapply(Table1$Metabolism, Table1$Treatment, median) 1 2 1.565 1.000

wilcox.test(Metabolism ~ Treatment, data = Table1, conf.int = TRUE) Wilcoxon rank sum test with continuity correction data: Metabolism by Treatment W = 50, p-value = 0.002647 alternative hypothesis: true location shift is not equal to 0 95 percent confidence interval: 0.2600396 0.7799804 sample estimates: difference in location 0.5543361

R gives a warning message for this analysis that it cannot calculate exact pvalues and confidence intervals because of ties. The p-value and the 95% confidence interval are corrected because there are ties amongst the Metabolism values. The p-value suggests that Metabolism is significantly different between the two Treatments (i.e. P < .05). Wilcoxon matched pairs This analysis uses the wilcox.test() function to compare the Metabolism Control and Metabolism Treatment1 columns in Table 2 assuming that these values come from the same individual (paired = TRUE). To proceed with this analysis, the Table 2 data need to be imported using: Table2