Docsity

SAS Data Analysis: Heart Rate Variability Analysis - Prof. Kathleen B. Welch, Assignments of Biostatistics

Toggle sidebar
bg1
Biostat 510
Homework 2
Due Thursday, January 24, 2008
Commands: 30 points total. Check that all parts of the syntax are included, and that there is no
incorrect syntax. Comments are not required, but will help to organize the commands.
Including output in Write-Up: 30 points total. See document below for points for each part of the
output.
Answers to Questions: 30 points total. See document below for points for each question.
Appearance of the output: 10 points.
If the weird fffff things shows up in their output, minus 5 points
If their output looks messy, with graphs not well integrated, minus 3 points
If their output is wrapped around, and doesn’t look neat, minus 2 points
SAS commands:
/*Question 1: libname statement*/
libname b510 "c:\documents and settings\kwelch\desktop\510";
/*Question 2: Proc Freq for BORN*/
proc freq data=b510.allgroups;
tables born;
run;
/*Question 3: Create a new data set*/
data b510.allgroups2;
set b510.allgroups;
RBORN=BORN;
if born="MICHIGAN" then rborn="MI";
if born="CALIFORNI" then rborn="CA";
if born="SOUTH DAK" then rborn="SD";
if born in ("ON","SA","TW","JN",
"SAO PAULO","CENTRAL",
"Karnataka","CHINA",
"CHQ","DELHI") then USBORN=0;
else USBORN=1;
if sex="F" then FEMALE=1;
if sex="M" then FEMALE=0;
hrdiff = hr2-hr1;
if group=. then delete;
run;
1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download SAS Data Analysis: Heart Rate Variability Analysis - Prof. Kathleen B. Welch and more Assignments Biostatistics in PDF only on Docsity!

Biostat 510

Homework 2

Due Thursday, January 24, 2008

Commands: 30 points total. Check that all parts of the syntax are included, and that there is no

incorrect syntax. Comments are not required, but will help to organize the commands.

Including output in Write-Up: 30 points total. See document below for points for each part of the

output.

Answers to Questions: 30 points total. See document below for points for each question.

Appearance of the output: 10 points.

If the weird fffff things shows up in their output, minus 5 points

If their output looks messy, with graphs not well integrated, minus 3 points

If their output is wrapped around, and doesn’t look neat, minus 2 points

SAS commands:

/Question 1: libname statement/

libname b510 "c:\documents and settings\kwelch\desktop\510";

/Question 2: Proc Freq for BORN/

proc freq data=b510.allgroups;

tables born;

run;

/Question 3: Create a new data set/

data b510.allgroups2;

set b510.allgroups;

RBORN=BORN;

if born="MICHIGAN" then rborn="MI";

if born="CALIFORNI" then rborn="CA";

if born="SOUTH DAK" then rborn="SD";

if born in ("ON","SA","TW","JN",

"SAO PAULO","CENTRAL",

"Karnataka","CHINA",

"CHQ","DELHI") then USBORN=0;

else USBORN=1;

if sex="F" then FEMALE=1;

if sex="M" then FEMALE=0;

hrdiff = hr2-hr1;

if group=. then delete;

run;

/Question 4: Proc Freq to check data/

proc freq data=b510.allgroups2;

tables rborn usborn female;

run;

proc freq data=b510.allgroups2;

tables usborn*rborn/list;

run;

/Question 5: Descriptives by RAN/

proc means data=b510.allgroups2;

class ran;

run;

/Question 6: Side-by-side boxplots/

proc sort data=b510.allgroups2;

by ran;

run;

proc boxplot data=b510.allgroups2;

plot (hr1 hr2 hrdiff)*ran/boxstyle=schematic;

run;

/Question 7: Independent samples t-tests/

proc ttest data=b510.allgroups2;

class ran;

var hr1 hr2 hrdiff;

run;

/Question 8: Paired t-test/

proc ttest data=b510.allgroups2;

paired hr1*hr2;

run;

proc ttest data=b510.allgroups2;

by ran;

paired hr1*hr2;

run;

/Question 9: One-sample t-test/

proc ttest data=b510.allgroups2;

var hrdiff;

run;

proc ttest data=b510.allgroups2;

by ran;

var hrdiff;

run;

State the alpha level that you are using for any statistical tests carried out for this homework. When reporting the results of a statistical test, include the test statistic, the degrees of freedom (both numerator and denominator df where applicable) and the p-value of the test. I used alpha=0.05 for all statistical tests, except the F-tests for homogeneity of variances, for which I used alpha=0.10. (3 pts)

14 "SAO PAULO","CENTRAL",

15 "Karnataka","CHINA", 16 "CHQ","DELHI") then USBORN=0; 17 else USBORN=1; 18 19 if sex="F" then FEMALE=1; 20 if sex="M" then FEMALE=0; 21 22 hrdiff = hr2-hr1; 23 if group=. then delete; 24 run; NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 1 at 22: NOTE: There were 69 observations read from the data set B510.ALLGROUPS. NOTE: The data set B510.ALLGROUPS2 has 68 observations and 12 variables.

  1. Use Proc Freq to get oneway tabulations of the variables: RBORN, USBORN, and FEMALE. Get a crosstab of USBORN by RBORN, using the list option to check your coding of USBORN (tables usborn*rborn/list;) a) Include the output for the oneway frequencies in your homework write-up. b) (1pt) How many and what percent of the sample were born in Michigan? c) (1pt) How many and what percent of the sample were born in the U.S.? d) (1pt) How many and what percent were female? e) (2pts) Do you think these values are an accurate representation of the class as a whole? Why or why not? Twenty students (29.41%) were born in Michigan. Fifty-six students (82.35%) were born in the U.S. Forty-eight (70.59 %) of the students were female. These may or may not have been an accurate representation of the class as a whole, because not all students were present on the first day of class. We can’t really tell if we had an accurate representation or not. (5 points for the output) The FREQ Procedure Cumulative Cumulative RBORN Frequency Percent Frequency Percent

AK 1 1.47 1 1. CA 6 8.82 7 10. CENTRAL 1 1.47 8 11. CHINA 1 1.47 9 13. CHQ 1 1.47 10 14. CO 1 1.47 11 16. DC 1 1.47 12 17. DELHI 1 1.47 13 19. GA 1 1.47 14 20. HI 1 1.47 15 22. IL 1 1.47 16 23. IN 1 1.47 17 25. JN 1 1.47 18 26. KS 1 1.47 19 27. Karnataka 2 2.94 21 30. MI 20 29.41 41 60. MN 1 1.47 42 61. NE 1 1.47 43 63. NY 3 4.41 46 67.

OH 7 10.29 53 77.

ON 1 1.47 54 79.

PA 3 4.41 57 83.

SA 1 1.47 58 85.

SAO PAULO 1 1.47 59 86.

SD 1 1.47 60 88.

TW 2 2.94 62 91.

VA 2 2.94 64 94.

WA 1 1.47 65 95.

WI 3 4.41 68 100.

Cumulative Cumulative USBORN Frequency Percent Frequency Percent


0 12 17.65 12 17. 1 56 82.35 68 100. Cumulative Cumulative FEMALE Frequency Percent Frequency Percent


0 20 29.41 20 29. 1 48 70.59 68 100.

  1. Get descriptive statistics for all numeric variables separately for those who ran and those who did not run using Proc Means with either a CLASS statement or a BY statement. a) Include this output in your write-up. b) (2 pts) What are the mean and standard deviation of HR1 for those who ran? For those who did not run? c) (2 pts) What are the mean and standard deviation of HR2 for those who ran? For those who did not run? d) (2 pts)What are the mean and standard deviation of HRDIFF for those who ran? For those who did not run? The mean of HR1 for those who ran was 72.53 beats per minute, SD=11.17. The mean of HR1 for those who did not run was 70.79 beats per minute, SD=8. The mean of HR2 for those who ran was 89.85 beats per minute, SD=14. The mean of HR2 for those who did not run was 70.15 beats per minute, SD=7. The mean of HRDIFF for those who ran was 17.32 beats per minute, SD=11. The mean of HRDIFF for those who did not run was -0.65 beats per minute, SD=5. (5 points for the output) The MEANS Procedure N RAN Obs Variable N Mean Std Dev Minimum Maximum

1 34 GROUP 34 4.2058824 2.0857295 1.0000000 7. ID 34 5.5294118 3.0672789 1.0000000 12. DISTANCE 34 4.8911765 7.9765325 0.1000000 35. HR1 34 72.5294118 11.1660614 54.0000000 110. HR2 34 89.8529412 14.8897613 67.0000000 126. USBORN 34 0.8235294 0.3869530 0 1. FEMALE 34 0.7352941 0.4478111 0 1. hrdiff 34 17.3235294 11.8263204 3.0000000 47.

appeared to be more spread, and the mean was higher than the median, indicating a skewed distribution. There were high outliers, but no low outliers for those who ran.

  1. Carry out an independent samples t-test to compare the mean of HR1, HR2, and HRDIFF for those who ran vs. those who did not run. Include the output in your write-up (5 pts). a) (3 pts) Discuss the results of the homogeneity of variance test for each of these variables. Report the F-tests for homogeneity of variance for each variable. Which t-test is appropriate for each variable? I used alpha=0.10 for the homogeneity of variances tests. The homogeneity of variances test for HR1 was not significant (F33,33=1.77, p=0.1072), therefore, use the equal variances t-test. (No points deducted if they didn’t report the F-test correctly. This will be graded in future). They should get credit for trying to get it right at this point. The homogeneity of variances test for HR2 was significant (F33,33=3.80, p=0.0002), therefore use the unequal variances t-test. The homogeneity of variances test for HRDIFF was significant (F33,33=4.87, p< 0.0001), therefore use the unequal variances t-test. b) (3 pts) What do you conclude about the mean of HR1, HR2, and HRDIFF for those who ran and those who did not run? (Include the t-test statistic, the degrees of freedom, and the p-value for each test in your statements). The mean of HR1 is not significantly different for those who ran vs. those who did not run (t 66 = 0.72, p=.4716). The mean of HR2 is significantly higher for those who ran than for those who did not run (t49.3 = 6.87, p < 0.0001). The mean of HRDIFF is significantly higher for those who ran than for those who did not run (t 46 = 8.07, p< 0.0001). Be sure they get the = sign and the < signs correct when reporting the p- values. The TTEST Procedure Statistics Lower CL Upper CL Lower CL Upper CL Variable RAN N Mean Mean Mean Std Dev Std Dev Std Dev Std Err HR1 34 68.633 72.529 76.425 9.0063 11.166 14.698 1. 1 HR1 34 67.863 70.794 73.726 6.7768 8.4019 11.059 1. 2 HR1 Diff (1-2) -3.05 1.7353 6.5201 8.4453 9.8811 11.91 2. HR2 34 84.658 89.853 95.048 12.01 14.89 19.599 2. 1 HR2 34 67.481 70.147 72.813 6.1624 7.6401 10.057 1. 2 HR2 Diff (1-2) 13.976 19.706 25.436 10.114 11.834 14.263 2. hrdiff 34 13.197 17.324 21.45 9.5388 11.826 15.567 2. 1 hrdiff 34 -2.517 -0.647 1.2228 4.3225 5.3591 7.0541 0. 2

hrdiff Diff (1-2) 13.525 17.971 22.416 7.847 9.181 11.066 2. T-Tests Variable Method Variances DF t Value Pr > |t| HR1 Pooled Equal 66 0.72 0. HR1 Satterthwaite Unequal 61.3 0.72 0. HR2 Pooled Equal 66 6.87 <. HR2 Satterthwaite Unequal 49.3 6.87 <. hrdiff Pooled Equal 66 8.07 <. hrdiff Satterthwaite Unequal 46 8.07 <. Equality of Variances Variable Method Num DF Den DF F Value Pr > F HR1 Folded F 33 33 1.77 0. HR2 Folded F 33 33 3.80 0. hrdiff Folded F 33 33 4.87 <.

  1. Carry out a paired samples t-test to compare the mean of HR1 to that of HR2 for everyone in the sample. a) (1 pt) Is there a difference in the mean of heartrate at time 1 vs. the mean of heartrate at time 2 for the group as a whole? b) Rerun the paired t-test separately for those who ran and those who did not run, using a BY statement. c) (1 pt) Is there a difference in the mean of heartrate at time 1 vs. the mean of heartrate at time 2 for those who ran? For those who did not run? (No points deducted if they didn’t include output, because I forgot to ask for it). The mean of HR2 was significantly higher than the mean of HR1 for all subjects combined (t 67 = -5.35, p<0.0001). They can report either a positive or negative t-test, because this is a two- sided test, it doesn’t matter. The TTEST Procedure Statistics Lower CL Upper CL Lower CL Upper CL Difference N Mean Mean Mean Std Dev Std Dev Std Dev Std Err HR1 - HR2 68 -11.45 -8.338 -5.229 10.99 12.844 15.457 1. T-Tests Difference DF t Value Pr > |t| HR1 - HR2 67 -5.35 <. The mean of HR2 was significantly higher than the mean of HR1 for those who ran (t 33 = -8.54, p<0.0001). They can report either a positive or negative t-test, because this is a two- sided test, it doesn’t matter. -------------------------------------------- RAN=1 -------------------------------------------- The TTEST Procedure Statistics Lower CL Upper CL Lower CL Upper CL

T-Tests Variable DF t Value Pr > |t| hrdiff 33 8.54 <. The mean of HRDIFF was not significantly different from zero for those who did not run (t 33 = -0.70, p=0.4864). The t-statistic should be negative here, because of the way it was calculated. -------------------------------------------- RAN=2 -------------------------------------------- The TTEST Procedure Statistics Lower CL Upper CL Lower CL Upper CL Variable N Mean Mean Mean Std Dev Std Dev Std Dev Std Err hrdiff 34 -2.517 -0.647 1.2228 4.3225 5.3591 7.0541 0. T-Tests Variable DF t Value Pr > |t| hrdiff 33 -0.70 0.

  1. Save all your commands as homework2.sas. Check that your program runs without any errors by submitting the entire command file, and scanning the log for errors. Include your SAS commands as the first part of your homework write-up. You will be graded on the commands, the output, and your writeup.