A)Check the Output Window to Be Sure Your Data Was Imported Correctly

A)Check the Output Window to Be Sure Your Data Was Imported Correctly

Homework 8 Key

1)Import the Excel file from homework 1 (heartrate_2005.xls from my web page) into SPSS. Even if you have your own version of this dataset, please download it from my web page: so everyone will be working with the same data.

a)Check the output window to be sure your data was imported correctly.

b)Recode Ran into a new variable, RRAN, so that 1=Ran and 2=Did Not Run. Create value labels for RRAN using syntax in the syntax window. To do this, use Transform > Recode > Into Different Variables. Enter RAN into the dialog box labeled "Numeric Variable > Output Variable". Then type RRAN into the box labeld "Output Variable" and click on "Change". Click on "Old and New Values" and type in the appropriate codes. Click on "Continue". When everything is filled out, click on "Paste". Then run the syntax from the syntax window. Your syntax should look like:

*------Syntax to read in Excel file .

GET DATA /TYPE=XLS

/FILE='H:\Biostat 510\heartrate_2005.xls'

/SHEET=name 'heartrate'

/CELLRANGE=full

/READNAMES=on .

*------Recode RAN into RRAN .

RECODE Ran(0=2) (1=1) INTO RRAN .

EXECUTE .

value labels RRAN (1) "RAN" (2) "Did not Run".

2)Compute BMI, appropriately calculated for everyone in the data set.

a)WTKG: The appropriate syntax for this new variable is shown below. Note that since all weights in this Excel file were measured in pounds, we can use the same transformation for all cases:

b)HTM: The appropriate syntax for this new variable is shown below:

c)Compute BMI as WTKG/HTM**2, using either point and click or syntax. If you use the point and click method, be sure to paste your commands to the syntax window.

i)Get a histogram and descriptive statistics for BMI for everyone in the data set.

COMPUTE wtkg = weight/2.2046 .

EXECUTE .

IF (ht_units="in") htm = height/39.37 .

EXECUTE .

IF (ht_units="cm") htm = height/100 .

EXECUTE .

COMPUTE BMI = wtkg/htm**2.

EXECUTE .

EXAMINE

VARIABLES=BMI

/PLOT BOXPLOT STEMLEAF

/COMPARE GROUP

/STATISTICS DESCRIPTIVES

/CINTERVAL 95

/MISSING LISTWISE

/NOTOTAL.

*------Alternative SPSS syntax for Histogram and Descriptives of BMI.

GRAPH

/HISTOGRAM=BMI

/TITLE= 'HISTOGRAM OF BMI'.

DESCRIPTIVES

VARIABLES=BMI

/STATISTICS=MEAN STDDEV MIN MAX .

The panel below shows that there were 3 observations missing for BMI, either because they did not have weight, or height.

The mean of BMI is 22.9, the median is 22.1, the minimum value is 16.83, the maximum is 37.46, and the standard deviation is 3.4. From the box-plot below we can see that there is one very high outlier.

The histogram shows that this variable is skewed to the right (positively skewed), with one high outlier.

3)Use Automatic Recode to create GEN_NUM (a numeric variable) from GENDER, a string or character variable.

AUTORECODE

VARIABLES=Gender /INTO GENNUM

/PRINT.

4)List all variables for the first 10 cases in your data set. Get a dictionary of your file, that shows all of the variables, the coding and any labels you have set up. (Output not shown to save space).

list variables=all

/cases = from 1 to 10.

display dictionary.

5)Get descriptive statistics for all numeric variables in your data. Include the output in your homework.

DESCRIPTIVES

VARIABLES=ID Monbir Daybir Yearbir Height Weight HRS_Exercise Distance Hrtrate1 Year Ran Hrtrate2 activity RRAN wtkg htm

BMI GENNUM

/STATISTICS=MEAN STDDEV MIN MAX .

There were 62 cases that were complete for all variables.

6)Get a histogram, box plot and descriptive statistics for HRTRATE2 for those who ran and those who did not run.

EXAMINE

VARIABLES=Hrtrate2 BY RRAN

/PLOT BOXPLOT HISTOGRAM

/COMPARE GROUP

/STATISTICS DESCRIPTIVES

/CINTERVAL 95

/MISSING LISTWISE

/NOTOTAL.

The sample mean of HRTRATE2 is much higher for those who ran than for those who did not run (mean = 93.70 and 75.23, respectively). The sample standard deviation is also greater for those who ran than for those who did not run (sd=18.3 and 10.2, respectively).

7)Calculate an independent samples t-test to compare HRTRATE2 for those who ran and vs. those who didn't run.

a)What are the null and alternative hypotheses? What are the results of the homogeneity of variance test? Report the test statistic, degrees of freedom and p-value. Which t-test results will you use?

b)What is the value of the t-statistic, the degrees of freedom and the p-value?

c)What do you conclude?

T-TEST

GROUPS = RRAN(1 2)

/MISSING = ANALYSIS

/VARIABLES = Hrtrate2

/CRITERIA = CI(.95) .

Null and alternative hypotheses:

H0: ran = rid not run

HA: ran ≠rid not run

Homogeneity of variances test:

H0: 2ran = 2rid not run

HA: 2ran ≠2rid not run

In order to be on the conservative side for the homogeneity of variances test, I used alpha=0.10 for the homogeneity of variances test. Since the p-value = 0.085, I would reject H0 and conclude that the variances are different. I then use the “Equal variances assumed” t-test. If I had used alpha=0.05 for this test, I would not have rejected H0 and would have used the unequal variances t-test.

The t-test is highly significant (t=5.114, degrees of freedom=43.7, p<0.001). I reject H0 and conclude that the mean of heartrate2 for those who ran is higher than the mean of heartrate2 for those who did not run.

8)Calculate a paired t-test to compare the means of HRTRATE1 and HRTRATE2 for all subjects.

a)What is the correlation of these two variables?

b)What is the value of the paired t-statistic, the degrees of freedom and the p-value?

c)What do you conclude about the mean of HRTRATE1 and HRTRATE2 for all students?

T-TEST

PAIRS = Hrtrate1 WITH Hrtrate2 (PAIRED)

/CRITERIA = CI(.95)

/MISSING = ANALYSIS.

These two variables are fairly highly positively correlated, as we would expect, because they are measured on the same students at two different times. The sample correlation between these two variables is 0.412, and the p-value is .001. The difference in the mean of hrtate1 and hratrate2 is 9.723 beats per minute. The results of the paired t-test indicate that there is a highly significant increase in the mean of hrtrate2 versus the mean of hrtrate1 (t=-4.856, degrees of freedom = 64, p<.001).

9)Calculate a paired t-test to compare HRTRATE1 vs. HRTRATE2 separately for those who ran and those who did not run.

a).

b)

c)What are the means of HRTRATE1 and HRTRATE2 for those who ran? For those who did not run?

d)What do you conclude about the change in mean Heart rate from time 1 to time 2 for those who ran? For those who did not run? Give the value of the paired t-test t statistic, the degrees of freedom and the p-value for those who RAN and did not RUN!.

RRAN = RAN

As shown in the output below, the mean of hrtrate1 and of hrtrate2 for those who ran were 72.43 and 93.70, respectively. The Correlation was 0.520. The paired t-test was highly significant (t = -7.374, df = 29, p<.001). So there was a highly significant increase in the mean of heartrate from time 1 to time 2 for those who ran.

RRAN = Did not Run

For those who did not run, hrtrate1 and hrtrate2 were highly significantly positively correlated (sample correlation = 0.731. However, there was no significant change in mean heartrate from time 1 to time 2, as shown by the paired t-test (t = 1.302, df = 34, p=.896). This is expected, since these students simply took their heartrates at two different time points without running in between.

SPLIT FILE

OFF.

10)Save your work

a)Save your syntax commands as homework8.sps. Hand them in with your writeup.

b)Resave your data set as heartrate.sav so that your any changes to the data set will be saved.

SAVE OUTFILE='C:\kwelch\510\2005\homework\heartrate.sav'

/COMPRESSED.

1