The following log file and comments illustrate how to perform the response feature analysis described in the preceding section.
. * 11.5.Isoproterenol.log . *
349 11.5. Response feature analysis using Stata
. * Perform a response feature analysis of the effect of race and dose of . * isoproterenol on blood flow using the data of Lang et al. (1995). For . * each patient, we will perform separate linear regressions of change in . * blood flow against log dose of isoproterenol. The response feature that . * we will use is the slope of each individual regression curve.
. *
. use C:\WDDtext\11.2.Long.Isoproterenol.dta, clear . *
. * Calculate the regression slope for the first patient . *
. regress delta_fbf logdose if id == 1 {1}
Source | SS df MS Number of obs = 6
---+--- F( 1, 4) = 71.86 Model | 570.114431 1 570.114431 Prob > F = 0.0011 Residual | 31.7339077 4 7.93347694 R-squared = 0.9473 ---+--- Adj R-squared = 0.9341 Total | 601.848339 5 120.369668 Root MSE = 2.8166 --- delta_fbf | Coef. Std. Err. t P>|t| [95% Conf. Interval]
---+--- logdose | 7.181315 .8471392 8.48 0.001 4.82928 9.533351 _cons | -14.82031 3.860099 -3.84 0.018 -25.53767 -4.10296 --- . predict yhat
(option xb assumed; fitted values) (22 missing values generated)
. graph delta_fbf yhat dose if dose ˜= 0 & id == 1,s(Oi) c(.l) xlog {2}
> xlabel(10,20,30,60,100,150,200,300,400) xtick(30,40,50,70,80,90,250,300,350)
> ylabel(0 5 to 25) gap(3)
{Graph omitted. See Figure 11.3} . *
. * Calculate some intra-patient statistics . *
. sort id
. by id: egen ldmean = mean(logdose) {3}
. by id: egen delta_fbfmean = mean(delta_fbf) {4}
. by id: egen ldsd = sd(logdose) {5}
. by id: egen delta_fbfsd = sd(delta_fbf) {6}
350 11. Repeated-measures analysis of variance
. by id: egen n = count(delta_fbf*logdose) {7}
. generate cross = (delta_fbf - delta_fbfmean)*(logdose - ldmean)/(n - 1) {8}
(26 missing values generated) . *
. * covis the within-patient covariance . *
. by id: egen cov = sum(cross) {9}
. *
. * r is the within patient correlation coefficient . *
. generate r = cov/(ldsd*delta_fbfsd) {10}
. *
. * Calculate slope coefficient for each patient . *
. generate slope = r*delta_fbfsd/ldsd {11}
. *
. * Reduce the data set to the last record for each patient.
. *
. by id: keep if _n == _N {12}
(132 observations deleted)
. list id slope race {13}
id slope race
1. 1 7.181315 White 2. 2 6.539237 White 3. 3 3.999704 White 4. 4 4.665485 White 5. 5 4.557809 White 6. 6 6.252436 White 7. 7 2.385183 White 8. 8 11.03753 White 9. 9 9.590916 White 10. 10 6.515281 White 11. 11 3.280572 White 12. 12 3.434072 White 13. 13 5.004545 White 14. 14 .5887727 Black 15. 15 1.828892 Black
351 11.5. Response feature analysis using Stata
16. 16 .3241574 Black 17. 17 1.31807 Black 18. 18 1.630882 Black 19. 19 .7392464 Black 20. 20 2.513615 Black 21. 21 1.031773 Black 22. 22 4.805953 Black . set textsize 120
. graph slope, by(race) oneway box {14}
{Graph omitted. See Figure 11.4}
. *
. * Do ranksum test on slopes.
. *
. ranksum slope, by(race) {15}
Two-sample Wilcoxon rank-sum (Mann-Whitney) test race | obs rank sum expected ---+---
White | 13 201 149.5
Black | 9 52 103.5
---+---
combined | 22 253 253
unadjusted variance 224.25 adjustment for ties -0.00 --- adjusted variance 224.25
Ho: slope(race==White) = slope(race==Black) z = 3.439
Prob > |z| = 0.0006 . *
. * Do t tests comparing change in blood flow in blacks and whites at . * different doses
. *
. use C:\WDDtext\11.2.Long.Isoproterenol.dta, clear {16} . sort dose
. drop if dose == 0
(22 observations deleted)
. by dose: ttest delta_fbf, by(race) unequal {17}
352 11. Repeated-measures analysis of variance
-> dose = 10
Two-sample t test with unequal variances
--- Group | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval]
---+--- White | 12 .7341667 .3088259 1.069804 .0544455 1.413888 Black | 9 .3966667 .2071634 .6214902 -.081053 .8743863 ---+--- combined | 21 .5895238 .1967903 .9018064 .1790265 1.000021 ---+---
diff | .3375 .3718737 -.4434982 1.118498
--- Satterthwaite's degrees of freedom: 18.0903
Ho: mean(White) - mean(Black) = diff = 0
Ha: diff < 0 Ha: diff ~= 0 Ha: diff > 0
t = 0.9076 t = 0.9076 t = 0.9076
P < t = 0.8 120 P > |t| = 0.3760 P > t = 0.1880
-> dose = 20
Two-sample t test with unequal variances
--- Group | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval]
---+--- White | 12 3.775833 .6011875 2.082575 2.4526285.099038 Black | 9 1.03 .3130229 .9390686 .308168 1.751832 ---+---
combined | 21 2.599048.4719216 2.162616 1.614636 3.583459 ---+---
diff | 2.745833 .6777977 1.309989 4.181677
--- Satterthwaite's degrees of freedom: 16.1415
Ho: mean(White) - mean(Black) = diff = 0
Ha: diff < 0 Ha: diff ~= 0 Ha: diff > 0
t = 4.0511 t = 4.0511 t = 4.0511
P < t = 0.9995 P > |t| = 0.0009 P > t = 0.0005
{Output omitted. See Table 11.1}
353 11.5. Response feature analysis using Stata
-> dose = 400
Two-sample t test with unequal variances
--- Group | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval]
---+--- White | 13 21.69308 2.163637 7.801104 16.97892 26.40724 Black | 9 5.586667 1.80355 5.410649 1.427673 9.74566 ---+---
combined | 22 15.10409 2.252517 10.56524 10.41972 19.78846 ---+---
diff | 16.10641 2.816756 10.2306 21.98222
--- Satterthwaite's degrees of freedom: 19.9917
Ho: mean(White) - mean(Black) = diff = 0
Ha: diff < 0 Ha: diff ~= 0 Ha: diff > 0
t = 5.7181 t = 5.7181 t = 5.7181
P < t = 1.0000 P > |t| = 0.0000 P > t = 0.0000
Comments
1 We regress change in blood flow against log dose of isoproterenol for the observations from the first patient. Note thatlogdose is missing when dose=0. Hence, only the six positive doses are included in this analysis.
The regression slope for this patient is 7.18. We could obtain the slopes for all 22 patients with the command
by id: regress delta_fbf logdose
However, this would require extracting the slope estimates by hand and re-entering them into Stata. This is somewhat tedious to do and is prone to transcription error. Alternatively, we can calculate these slopes explic- itly for each patient using equation (2.6), which we will do below.
2 This graph shows the regression line and individual data points for the first patient. It is similar to Figure 11.3.
3 The commandegen xbar= mean(x) creates a new variable xbarthat equals the mean ofxover the entire data set. When preceded with theby z:prefix, this command calculates separate means ofxfrom subsamples of the data that have identical values ofz. Hence, this command calculates ldmeanto equal the mean log dose of isoproterenol for theith subject.
Missing values are excluded from this mean. In the calculations given below we will denote this meanx. The individual values oflogdosefor theithpatient will be denotedxj.
354 11. Repeated-measures analysis of variance
In this example,ldmeanis constant for all patients except patient 8 who has missing blood flow values at several doses.
4 This command calculates delta fbfmean to equal the mean change in forearm blood flow for theithsubject. We will denote this valuey. The individual values ofdelta fbf for theithpatient will be denotedyj. 5 This command calculatesldsdto equal the estimated standard deviation
oflogdosefor theithpatient, which we denotesx.
6 The variabledelta fbfsdequals the standard deviation ofdelta fbf for the ithpatient, which we denotesy.
7 This command defines n to be the number of non-missing values of delta fbf*logdosefor theithpatient;delta fbf*logdoseis missing if either delta fbforlogdoseis missing.
8 This generate command calculates cross to equal (yj−y)(xj−x)/
(n−1).
9 This egencommand calculates covto equal the sum of cross over all records with identical values ofid. In other words, covis the sample covariance ofdelta fbfwithlogdosefor theithpatient, which was defined in equation (2.1) to besx y =
(yj−y)(xj−x)/(n−1).
10 The variabler =sx y/(sxsy) is the sample correlation coefficient for the ithpatient (see equation (2.2)).
11 The variableslope=b =r sy/sx is the slope estimate of the regression line for theithpatient (see equation (2.6)).
12 We still have one record per observation sorted byid. When used with theby id:prefix, the system constant Nequals the number of records with the current value ofid; nis set to 1 for the first record with a new value ofidand is incremented by 1 for each succeeding record with the sameidvalue. Hence, thiskeepcommand deletes all but the last record corresponding to each patient. (Note thatslopeis constant for all records corresponding to the same patient. Thus, it does not matter which of the available records we keep for each patient.)
13 We list the individual slope estimates for each patient. Note that the highlighted slope estimate for the first patient is identical to the estimate obtained earlier with theregresscommand.
14 This graph, which is similar to Figure 11.4, highlights the difference in the distribution of slope estimates between blacks and whites.
15 This ranksum command performs a Wilcoxon–Mann–Whitney rank sum test of the null hypothesis that the distribution of slopes is the same for both races. The test is highly significant, giving aPvalue of 0.0006.
355 11.6. The area-under-the-curve response feature
16 The precedingkeepcommand deleted most of the data. We must read in the data set before performingttests at the different doses.
17 Thisttestcommand performs independentttests ofdelta fbf in blacks and whites at each dose of isoproterenol. The output for doses 60, 150 and 300 have been omitted. The highlighted output from this command is also given in Table 11.1.