-
Notifications
You must be signed in to change notification settings - Fork 192
/
baci-fry-power.sas
135 lines (109 loc) · 4.28 KB
/
baci-fry-power.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* This is a power analysis for monitoring for fry example presented in the notes */
/* Read in the scenarios (i.e. the design specifications) and generate the
data for use in the power analysis. The data are expected values for
each observed data point. These are then passed to Proc Mixed for 'analysis'
as outlined in the Stroup paper */
/* This is the monitoring for fry example presented in the notes */
/* The input data are the
Alpha level (usually .05 or .10)
Variance components
std_site -> site to site STANDARD DEVIATION
std_year -> year to year STANDARD DEVIATION
std_site_year -> site-year interaction STANDARD DEVIATION
std_Resid -> within site sub-sampling STANDARD DEVIATION
Sub-sampling sample sizes.
We allow for different sample sizes in the treatment-time combinations
but all sites in that combination must have the same sample size.
It is possible to generalize this; contact me for details.
n_TA -> number of Resids in Treatment-After combination
n_TB -> number of Resids in Treatment-Before combination
n_CA -> number of Resids in Control-After combination
n_CB -> number of Resids in Control-Before combination
Number of sites
We allow for a different number of sites for Treatment and Control areaa
ns_T -> number of treatment sites
ns_C -> number of control sites
Number of years of monitoring before/after impact
ny_b
ny_a
Marginal Means
These are used to form the BACI contrast of interest
mu_TA, mu_TB, mu_CA, mu_CB
*/
options nodate noovp orientation=landscape;
title 'Fry example BACI power analysis';
ods pdf file='baci-fry-power-SAS.pdf';
%include '../baci-power.sas'; /* get the baci power macro */
*---part500b;
proc datasets; /* delete any existing data set */
delete all_power;
run;
data scenarios;
input alpha
sdSite sdYear sdSiteYear sdResid
n_TA n_TB n_CA n_CB
ns_T ns_C
ny_B ny_A
mu_TA mu_TB mu_CA mu_CB;
datalines;
.05 .75 .25 .10 .75 3 3 3 3 3 3 3 2 5.0 5.5 4.5 4.5
.05 .75 .25 .10 .75 6 6 6 6 3 3 3 2 5.0 5.5 4.5 4.5
.05 .75 .25 .10 .75 9 9 9 9 3 3 3 3 5.0 5.5 4.5 4.5
.05 .75 .25 .10 .75 6 6 6 6 3 3 3 4 5.0 5.5 4.5 4.5
run;
options mprint;
data _null_; /* compute the power for the various scenarios */
set scenarios;
call execute(
'%baci_power(alpha=' || alpha ||
" , sdSite= " || sdSite ||
" , sdYear= " || sdYear ||
" , sdSiteYear=" || sdSiteYear ||
" , sdResid=" || sdResid ||
" , n_TA=" || n_ta ||
" , n_TB=" || n_tb ||
" , n_CA=" || n_CA ||
" , n_CB=" || n_CB ||
" , ns_T=" || ns_t ||
" , ns_C=" || ns_C ||
" , ny_B=" || ny_B ||
" , ny_A=" || ny_A ||
" , mu_TA=" || mu_TA ||
" , mu_TB=" || mu_TB ||
" , mu_CA=" || mu_CA ||
" , mu_CB=" || mu_CB || ");" );
* put "***temp***" temp;
run;
*---part500e;
proc print data=all_power;
title2 'Compute power';
run;
data scenarios;
merge scenarios all_power;
run;
proc print data=scenarios split="_" label;
title2 'Estimated power under various scenarios';
run;
proc print data=scenarios split="_" label;
var alpha
sdSite sdYear sdSiteYear sdResid
n_TA n_TB n_CA n_CB
ns_T ns_C
ny_B ny_A
mu_TA mu_TB mu_CA mu_CB power;
run;
ods pdf close;
/* Create LaTeX files for inclusion by my notes */
%include "../../MyLatexTagset.sas"; run;
title;
footnote;
ods listing;
ods tagsets.mycolorlatex file='baci-fry-power-SAS-500.tex' (notop nobot) stylesheet="sas.sty";
proc print data=scenarios split="_" label noobs;
var alpha
/* sdSite sdYear sdSiteYear sdResid */
n_TA n_TB n_CA n_CB
ns_T ns_C
ny_B ny_A
mu_TA mu_TB mu_CA mu_CB power;
ods tagsets.mycolorlatex close;