Dear Statalist,
I have an issue with "disappearing" observations. I'm using the user-contributed -traj- package to plot trajectories of lung function. I have tried using t* (date of participation) on the x axis, and this works fine. But when I try to plot the graph using chronological age (age in years), observations in both ends are dropped. I cannot figure out why, and wonder if anyone have any ideas based on the syntax below?
This one works fine, and creates the graph I'm expecting (using date of participation):

Whereas this one doesn't (age span should be 13-43 y):

I have an issue with "disappearing" observations. I'm using the user-contributed -traj- package to plot trajectories of lung function. I have tried using t* (date of participation) on the x axis, and this works fine. But when I try to plot the graph using chronological age (age in years), observations in both ends are dropped. I cannot figure out why, and wonder if anyone have any ideas based on the syntax below?
Code:
** Generate time variables from the first date in our data material (Oct 3 95) ** gen t1 = PartDat_1 - 13059 gen t2 = PartDat_2 - 13059 gen t3 = PartDat_3 - 13059 gen t4 = PartDat_4 - 13059 gen t5 = PartDat_5 - 13059 forval i = 1/5 { replace t`i' = t`i'/365.25 }
This one works fine, and creates the graph I'm expecting (using date of participation):
Code:
traj, var(FEV1_1 FEV1_2 FEV1_3 FEV1_4 FEV1_5) indep(t1-t5) risk (Sex) model(cnorm) min(-999) max(999) order(2 2 2 2 2 2 2 2 2) trajplot, xtitle(Time(years)) ytitle(ppFEV1) xlabel(0(1)25) ylabel(50(10)130)
Whereas this one doesn't (age span should be 13-43 y):
Code:
traj, var(FEV1_1 FEV1_2 FEV1_3 FEV1_4 FEV1_5) indep(age1 age2 age3 age4 age5) risk (Sex) model(cnorm) min(-999) max(999) order(2 2 2 2 2 2 2 2 2) trajplot, xtitle(Age(years)) ytitle(ppFEV1) xlabel(13(1)43) ylabel(50(10)130)
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id t1 t2 t3 t4 t5) double(age1 age2 age3 age4 age5 FEV1_1 FEV1_2 FEV1_3 FEV1_4 FEV1_5 Sex) 1 1.4592744 . . 12.52019 . 18.1 . . 29.1 . 86.62 . . 65.2 . 1 2 1.155373 5.119781 . 12.12868 22.65024 13.8 17.7 . 24.7 35.3 . 80.422 . 88.2 39.961 1 3 . . 12.194387 . 22.288843 . . 16.1 . 26.2 . . 88.291 . 56.984 0 4 1.2046543 . . . 22.06434 14.6 18.5 . . 35.4 97.032 . . . 53.89 0 5 1.3716632 . . 12.399726 22.056126 17.2 . . 28.2 37.8 53.001 . . . 37.752 1 6 . . 11.175907 . 23.37577 . . 13.3 . 25.5 . . 96.777 . 65.761 1 7 1.4373716 . . 12.670774 23.36208 17.2 . . 28.5 39.2 82.154 . . 66.6 47.019 0 8 .9965777 . . . 22.7269 17.3 . . . 39.1 75.449 . . . 97.719 0 9 1.5879534 5.28679 . 12.438056 . 14.9 18.5 . 25.8 35.5 76.377 75.55 . 113.8 . 0 10 .3504449 . . 11.315537 22.99521 15.8 . . 26.8 38.4 78.165 . . 96.7 88.194 0 11 .6680356 4.4490075 . 11.334702 23.9206 15.3 19.1 . 26 37.4 77.537 84.078 . 102.4 92.486 1 12 .5722108 . . 12.706366 23.05818 18.3 . . 30.4 40.8 75.976 . . 99.5 97.592 0 13 .57494867 . . . 22.63381 17.3 . . . 39.4 75.449 . . . 95.047 0 14 .6160164 . . 11.419576 . 16.3 . . 27.1 . 62.951 . . 98.3 . 0 15 1.5523614 . . . 22.32991 14.2 . . . 35 73.775 . . . 93.855 0 16 1.3086927 . . 12.517454 22.02601 13.2 . . 24.5 34 69.831 . . 92.5 92.198 1 17 .021902807 4.4490075 . 12.06297 23.8193 12.9 17.3 . 25 34.9 68.858 93.152 . . 91.481 0 18 . . 12.073922 . 22.32991 . . 15.2 . 25.4 . . 74.233 . 110.357 1 19 .366872 . . 12.6872 23.039015 18.2 . . 30.5 40.9 71.952 . . 93.2 91.327 0 20 .9993156 5.034908 . 12.569473 23.9206 13.8 17.9 . 25.4 35.4 72.1 98.985 . . 95.29 0 21 1.5550992 . . . 23.915127 15.1 . . . 35.7 74.257 . . . 91.89 0 22 1.3251197 5.371663 . 11.520876 . 14.6 18.5 . 24.8 36.4 71.706 82.674 . 92.1 . 0 23 .07392197 . . . 22.045174 14.9 . . . 36.8 68.34 . . . 93.376 1 24 .6160164 . . 11.559206 23.8193 15.5 . . 26.4 37.4 72.439 . . 90.3 98.769 0 25 .4435318 . . 11.24983 . 13.3 . . 24.1 35 53.786 . . 99.4 . 0 26 .3531828 . . 11.367557 22.899384 14.8 19 . 25.8 37.4 63.7 . . 92.5 87.243 1 27 .3832991 . . 12.503764 23.915127 17 . . 29.1 39.3 71.727 . . . 99.243 0 28 .3477071 . . 11.326488 . 14.3 . . 25.3 . 77.094 . . 109.2 . 0 29 .4845996 . . 11.411362 . 18.4 . . 29.4 . 73.304 . . 103.8 . 0 30 1.1279945 . . . 22.540726 15.5 . . . 36.9 66.876 . . . 103.47 0 31 .4380561 . . 11.195072 . 15.4 . . 26.1 38 78.223 . . 101.9 . 0 32 .3531828 . . 11.329226 23.000685 14.5 18.8 . 25.5 37.2 73.854 . . 102.1 99.423 0 33 1.284052 4.7008896 . 12.301164 22.19028 14.7 18.1 . 25.8 35.7 74.802 97.593 . 100.4 98.454 0 34 .26830938 . . 11.87132 . 17.7 . . 29.3 . 70.969 . . 105.3 . 1 35 .3449692 . . . 23.000685 13.7 . . . 36.3 70.349 . . . 102.194 0 36 0 . . 11.980835 22.017796 15 . . 27 37 68.786 . . . 82.327 1 37 .3312799 5.371663 . 11.345654 23.79466 13.5 18.4 . 24.5 36.1 72.112 84.447 . 64.3 80.48 1 38 . . 11.520876 . 23.79466 . . 14.4 . 25 . . 65.736 . 64.925 0 39 1.1389459 . . 12.03833 . 13.9 . . 24.8 . 72.926 . . 73.7 . 0 40 . . 11.545517 . 22.554415 . . 15.6 . 26.6 . . 73.362 . 56.341 1 41 .9774128 . . 12.147844 22.540726 18.5 . . 29.7 40.1 69.758 . . 77.1 73.953 1 42 .5338809 . . 11.65503 . 18.2 . . 29.4 . 69.283 . . 61 . 0 43 . . 12.323067 . 22.21492 . . 17.5 . 27.4 . . 64.993 . 76.751 0 44 1.6646132 . . 12.339494 . 14.2 17.7 . 24.9 . 69.496 . . 57.2 . 1 45 1.629021 . . 12.588638 23.15674 14.2 . . 25.2 35.7 64.582 . . 66.3 61.647 0 46 .57494867 . . 11.613963 22.466805 17 . . 28.1 38.9 68.636 . . 76.9 77.21 1 47 .1889117 . . 11.696098 . 16.3 . . 27.8 38.2 73.791 . . 58 . 0 48 .15331964 . . . 23.000685 17.8 . . . 40.7 67.654 . . . 69.433 1 49 .4626968 . . . 22.72964 18.9 . . . 41.1 65.465 . . . 91.719 1 50 .1560575 . . 12.071184 22.29158 13.9 . . 25.8 36 62.291 . . . 73.904 1 51 .6132786 . . 11.561944 . 16.2 20.3 . 27.2 . 64.921 . . 76.3 . 1 52 1.155373 . . 11.983573 23.802876 13.5 . . 24.3 34.3 68.236 . . 79.7 79.678 0 53 1.1307324 . . 11.994524 22.59822 14.7 . . 25.5 36.1 67.305 . . 79.1 68.085 1 54 1.629021 . . 11.939767 22.06434 17.4 . . 27.7 37.8 62.354 . . 88.9 64.185 1 55 .4188912 . . 11.66872 23.93429 17 . . 28.2 39.1 72.38 . . 74 92.038 0 56 . . 11.055442 . 23.8193 . . 17.5 . 29.8 . . 74.27 . 63.18 0 57 . . 12.30664 . 22.004107 . . 16.9 . 26.6 . . 71.571 . 71.909 0 58 . . 11.13484 . 23.79466 . . 18.7 . 30.1 . . 74.154 . 74.941 0 59 .6570842 . . 11.367557 . 13.9 17.7 . 24.6 . 74.644 . . 74.2 . 1 60 . . 11.05818 . 22.899384 . . 17.7 . . . . 72.435 . 79.693 0 61 .9664613 . . 12.386037 21.94661 17.2 . . 28.6 38.2 68.462 . . . 87.489 0 62 .3230664 . . 12.59685 23.915127 16.8 . . 29 39 73.676 . . . 67.027 1 63 .6351814 . . . 23.93429 14.2 18.1 . . 36.3 68.777 . . . 66.715 1 64 . . 11.690623 . 21.9603 . . 15.4 . 25.7 . . 75.804 . 54.709 1 65 . . 11.926078 . 23.93429 . . 17.4 . 28 . . 76.166 . 70.158 0 66 1.4209446 . . . 22.32991 19.9 . . . 40.8 67.216 . . . 87.525 0 67 .4435318 . . . 22.160164 17.8 . . . 39.5 61.596 . . . 94.963 1 68 .17522246 . . . 21.98768 17.1 . . . 38.9 73.42 . . . 66.606 0 69 .476386 . . 11.383984 23.8193 18.7 . . 29.6 41.4 68.295 . . 74.6 80.575 1 70 .07665982 . . 12.156057 22.160164 14.6 . . 26.7 36.6 73.977 . . . 63.861 0 71 1.2073922 5.119781 . 11.074607 . 13 16.8 . 22.8 . 75.9 71.225 . 66.6 . 0 72 1.557837 5.371663 . 12.626967 23.091034 14.4 18.1 . 25.4 35.9 72.213 69.478 . 73.4 70.619 0 73 1.3305955 . . 11.482546 . 15.3 19 . 25.5 37.1 83.972 . . 104.6 . 1 74 1.303217 5.28679 . 11.44148 23.34018 15.1 19 . 25.3 37.2 101.927 92.883 . 97.1 93.713 0 75 . . 11.460644 . 22.537987 . . 14 . 25.1 . . 85.736 . 85.968 0 76 1.4620123 . . 12.323067 22.30527 17 . . 27.8 37.8 93.302 . . 88.3 84.194 0 77 .20807666 . . 11.830254 22.121834 18.2 . . 29.8 40.1 92.875 . . 91.4 94.717 0 78 . . 11.367557 . 23.78645 . . 16.9 . 28.6 . . 84.615 . 93.98 1 79 .6324435 . . 11.310061 . 15.5 . . 26.2 . 95.518 . . 95.9 . 1 80 .4380561 . . 11.611225 . 17.3 . . 28.5 39.4 96.266 . . 89.4 . 0 81 1.6399726 . . 11.901438 23.791924 17.7 . . 28 38.2 92.279 . . 96.2 95.849 0 82 . . 11.000685 . 23.868584 . . 14.2 . 25.8 . . 86.912 . 86.881 0 83 0 . . 12.328542 22.15195 15.5 20.2 . 27.8 37.7 89.528 . . 95.9 96.193 1 84 . . 11.329226 . 23.868584 . . 14.6 . 26.3 . . 102.25 . 88.003 0 85 .3696099 . . 11.65503 22.540726 18.4 . . 29.6 40.5 92.39 . . 92.9 92.887 1 86 .366872 . . 11.27173 22.658453 17.2 . . 28.1 39.5 89.706 . . 101.8 100.688 1 87 .4188912 . . . 23.304586 17.7 . . . 40.6 96.955 . . . 92.813 0 88 1.3661876 . . . 22.141 19.5 . . . 40.3 90.749 . . . 93.446 1 89 1.0896646 . . . 23.93429 14 . . . 35.4 87.612 . . . 95.821 1 90 .3613963 . . 11.419576 . 18.9 . . 29.9 . 96.941 . . 96.5 . 1 91 . . 11.460644 . 23.79466 . . 18.3 . 30.1 . . . . 82.598 0 92 .13689254 . . 12.09035 23.93429 18.4 . . 30.4 40.8 87.729 . . . 89.458 0 93 . . 12.05202 . 22.21766 . . 15.8 . 26 . . 93.729 . 91.891 0 94 .6324435 . . 11.296372 . 15.8 . . 26.5 . 86.67 . . 89.4 . 1 95 1.0924025 . . . 22.58179 13.7 . . . 35.2 103.556 . . . 83.587 1 96 . . 11.997262 . 22.212183 . . 16.1 . 26.3 . . 91.751 . 91.357 0 97 . . 11.304585 . 22.962355 . . 13.9 . 25.6 . . 97.265 . 89.224 1 98 1.319644 4.4490075 . 12.52293 22.058865 16 19 . 27.2 36.7 89.907 86.437 . 94.4 86.683 0 99 .4435318 . . 11.904175 . 17 . . 28.5 . 88.185 . . 100.9 . 1 100 1.190965 5.28679 . 12.210814 . 13.4 17.3 . 24.4 . 78.532 91.04 . 96.6 . 0 end label values Sex Sex label def Sex 0 "Kvinne", modify label def Sex 1 "Mann", modify
Comment