1. This is dataplot macro     comparative_k1_analysis.dp.dp     3/28/19 => 4/11/19
2. Purpose: Assess equivalence (and drift) across the k=1 single factor (usually discrete)
3. Date: 3/28/19
4.
5. Input (Required):
6.   y        (vector) = Response variable
7.   x        (vector) = Factor 1 (^ndx levels)
8.   sty      (string) = Vertical   axis label
9.   stx      (string) = Horizontal axis label
10.
11. Input (Optional):
12.   frame    (string) = subset of interest                             (default = all data)
13.   header1  (string) = first header line       (usually a title line) (default = none)
14.   trailer  (string) = name of calling routine (e.g., draft69.dp)     (default = none)
15.   trailer2 (string) = name of input data file (e.g., draft69.dat)    (default = none)
16.   currdate (string) = current date            (e.g., 3/28/19)        (default = none)
17.
18. Output:
19.    pages of plots
20.
21. -----start point-----
22.
23let bugsw = 0
24.
25. -----Step 1: Extract out the target subset for analysis-----
26.
27if bugswcvp = 1; print " At (k1_equivalence_plot.dp, step 1): at start of subsetting via frame"
28   stat v
29end if
30.
31delete yz; let yz = y
32delete xz; let xz = x
33.
34if frame exists
35   retain yz xz ^frame
36end if
37.
38if bugsw = 1
39   print " "
40   print " At (k1_equivalence_plot.dp, end of step 1): after subsetting via frame"
41   stat v
42   pause
43end if
44.
45. -----Step 10: Plot the data-----
46.
47delete dx; let dx = distinct x
48delete ndx; let ndxz = number dx
49delete mindx; let mindx = minimum dx
50delete maxdx; let maxdx = maximum dx
51.
52delete dxz; let dxz = distinct xz
53delete ndxz; let ndxz = number dxz
54delete mindxz; let mindxz = minimum dxz
55delete maxdxz; let maxdxz = maximum dxz
56.
57let lowerxz = mindx
58let upperxz = maxdx
59. let lowerxz = mindxz
60. let upperxz = maxdxz
61.
62minor x1tic number 0
63.
64. -----Step 11: Scatter plot of the data-----
65.
66let string header2 = Scatter Plot
67char X all; lines bl all
68y1label ^sty; x1label ^stx
69xlim ^lowerxz ^upperxz
70plot yz xz
71.
72call annotate.dp
73.
74. -----Step 12: Scatter plot of the data  with Superimposed Means-----
75.
76char X all; lines bl all
77plot yz xz
78.
79delete jz j2z mz
80loop for jz = 1 1 ^ndxz; let j2z = dxz(jz); let mz(jz) = mean yz subset xz ^j2z; end loop
81pre-erase off; limits freeze; char circle; char hw 1.3 1; char fill on; char color red
82plot mz dxz
83.
84call annotate.dp
85pre-erase on; limits; xlim ^lowerxz ^upperxz
86char color blue
87.
88. -----Step 13: Scatter plot of the data  with Superimposed Means (& ANOVA results)-----
89.
90char X all; char hw 2 1; char color blue all
91lines bl all
92plot yz xz
93.
94delete jz j2z mz
95loop for jz = 1 1 ^ndxz; let j2z = dxz(jz); let mz(jz) = mean yz subset xz ^j2z; end loop
96pre-erase off; limits freeze; char circle; char hw 1.3 1; char fill on; char color red
97plot mz dxz
98. pause
99.
100anova yz xz
101.
102let fcdf = statcdf; set write decimals 4; let stout = number to string fcdf
103color blue; let string stout2 = ^stout% (=> ^stx&s not significantly different)
104if fcdf >= 95;
105   color red; let string stout2 = ^stout% (=> ^stx&s are significantly different)
106end if
107move 16 87; just left; hw 2.4 1.2; text ANOVA Fcdf = ^stout2
108.
109color blue
110call annotate.dp
111pre-erase on; limits; xlim ^lowerxz ^upperxz
112char color blue
113.
114. -----Step 14a: Scatter plot of the data  with fitted line-----
115.
116fit yz xz
117. pause
118.
119char bl all; char X bl; char hw 2 1
120lines bl all; lines bl solid; line color red red
121plot yz pred vs xz
122call annotate.dp
123.
124. -----Step 14b: Scatter plot of the data  with fitted line (and t slope)-----
125.
126fit yz xz
127.
128char bl all; char X bl
129lines bl all; lines bl solid; line color red red
130plot yz pred vs xz
131.
132skip 1
133read parameter dpst1f.dat slope sdslope tslope
134let tslope2 = abs(tslope)
135print slope sdslope tslope tslope2
136print dpst1f.dat
137. pause
138.
139move 16 87, just left; hw 2.4 1.2
140color blue; let string stout = Slope = ^slope   t(Slope) = ^tslope (=> Drift over ^stx is not significant)
141delete nz; let nz = number yz; let nuz = nz - 2
142delete cutz; let cutz = tppf(.975,nuz)
143if tslope2 >= cutz
144   color red; let string stout =  Slope = ^slope   t(Slope) = ^tslope (=> Drift over ^stx is significant)
145end if
146move 16 87; text ^stout
147.
148color blue
149call annotate.dp
150.
151. -----Step 15: Mean plot of the data-----
152.
153let string header2 = Mean Plot
154xlim ^lowerxz ^upperxz
155line color blue all
156char circle bl; char fill on off; char hw 1.1 0.9; lines solid dotted
157char offset -.05 .10
158y1label: Mean ^sty; x1label ^stx
159mean plot yz xz
160.
161call annotate.dp
162delete header2
163.
164.
165. -----Step 99: Finish up-----
166.
167char hw 2 1 all
168xlim
169.
170