Question: . Dual-photon absorptiometry (DPA) is a method to measure bone mineral density and evaluate the quality of bone being considered for transplant. The DPA technique
. Dual-photon absorptiometry (DPA) is a method to measure bone mineral density and evaluate the quality of bone being considered for transplant. The DPA technique is expensive and often unavailable. Therefore, an alternative method is to use a bone score based on four less expensive bone quality measures: i) Singh index (singh), ii) CC ratio (ccratio), iii) calcar width (calcar), and iv) cortical shaft index (csi). The data stored in Bonescor2.dat were collected by Renee Smith of the Bone and Joint Research Lab at the VA Medical Center in Salt Lake City, UT. She used the data to compare the two methods of quantifying bone mineral density. We will use the data here to reinforce the concept of programming for missing values. Oh ... please bear with the details of this homework problem ... it seems longer than it really is.
a. First, read the bone data arising from 30 subjects that is stored in Bonescor2.dat into a temporary data set called bonescore1. The first column contains the variable singh, the second column contains the variable ccratio, the third column contains the variable csi, and the fourth column contains the variable calcar. The fifth column contains the bone score (bone) that Renee Smith formulated from the first four measures, and the sixth column contains the gold standard dual-photon absorptiometry (dpa) measures. When reading in the data, take note that there are a few missing values in the data set.
After, you've successfully read in the data, create four new variables in your bonescore1 data set: flag1, flag2, flag3, and flag4 according to the following specifications:
Value of flag variable Flag variable 1 2 3 flag1 singh 4 4 < singh 5 singh > 5 flag2 ccratio > 0.67 0.52 < ccratio 0.67 ccratio 0.52 flag3 csi 0.55 0.55 < csi 0.65 csi > 0.65 flag4 calcar 6 6 < calcar 7 calcar > 7
So, for example, flag1 should be assigned the value 1 if singh is less than or equal to 4, flag1 should be assigned the value 2 if singh is greater than 4, but less than or equal to 5, and flag1 should be assigned the value 3 if singh is greater than 5.
In writing the necessary if-then-else statements to create the four new variables intentionally fail to program for missing values. That is, for example, your if-then-else statement for the creation of flag1 should contain just three lines one if condition, and two else-if conditions. Similarly, the if-then-else statements for the creation of flag2, flag3, and flag4 should each contain three lines. After you've created the four flag variables, create a fifth new variable called ourscore, which is merely the sum of the four flag variables. Print the bonescore1 data set, and observe that one of the values for flag1 and one of the values for flag3 have been improperly assigned. Why? Also note that the errors in flag1 and flag3 also cause errors in the ourscore variable. Why?
b. Now, let's try to fix the errors in our last if-then-else statements. Create a new data set called bonescore2 by re-reading the data contained in Bonescor2.dat. Copy your if-then-else statements from your bonescore1 data step into your bonescore2 data step. Edit the if-then-else statements by adding an else-if condition to the end of each one that supposedly programs for missing values. For example, add:
else if singh = . then flag1 = .;
to the end of your if-then-else statements that create the flag1 variable. Make a similar mistake while attempting to program for missing values when creating each new flag variable. Print the bonescore2 data set, and observe that one of the values for flag1 and one of the values for flag3 are still improperly assigned. Why is this the case? Again note that the errors in flag1 and flag3 have been propagated to the ourscore variable.
c. Okay, let's finally get it right! Create a new data set called bonescore3 by re-reading the data contained in Bonescor2.dat. Copy your if-then-else statements from your bonescore1 data step into your bonescore3 data step. Now, edit the if-then-else statements by placing the missing value conditions in the correct locations.
After completing this assignment, you should be able to appreciate not only the critical importance of programming for missing values, but doing it correctly!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
