The analysis begins with the creation of an internal 'teratology' dataset. The variables 'litter', 'group', 'n' (total number of observations), and 'y' (number of successes) are read. Indicator variables (z2, z3, z4) are generated for groups 2, 3, and 4 respectively. Next, PROC LOGISTIC is used to fit a logistic regression model on the y/n ratio with indicator variables as predictors, without initial scale correction. Finally, PROC NLMIXED is employed to fit a nonlinear mixed model, modeling the binomial response with a random effect ('u') per 'litter' to capture overdispersion, estimating the parameters alpha, beta2, beta3, beta4, and sigma.
Data Analysis
Type : CREATION_INTERNE
Data is directly integrated into the SAS script via the 'cards' instruction in the DATA step, meaning it is internally created and does not depend on external sources or SASHELP libraries.
1 Code Block
DATA STEP Data
Explanation : This DATA step creates a dataset named 'teratology'. The variables 'litter' (litter), 'group' (treatment group), 'n' (total number of individuals), and 'y' (number of affected individuals) are read from the data lines ('cards'). Three indicator variables, z2, z3, and z4, are created to represent treatment groups 2, 3, and 4 respectively. If the 'group' variable is equal to 2, z2 takes the value 1, and 0 otherwise. The same principle applies to z3 (group=3) and z4 (group=4), which facilitates the inclusion of groups in statistical models.
IF group=2THEN z2=1; IF group=3THEN z3=1; IF group=4THEN z4=1;
5
CARDS;
6
11101
7
21114
8
31129
9
4144
10
511010
11
61119
12
7199
13
811111
14
911010
15
101107
16
1111212
17
121109
18
13188
19
141119
20
15164
21
16197
22
1711414
23
181127
24
191119
25
201138
26
211145
27
2211010
28
2311210
29
241138
30
2511010
31
261143
32
2711313
33
28143
34
29188
35
301135
36
3111212
37
322101
38
33231
39
342131
40
35212 0
41
362144
42
37292
43
382132
44
392161
45
40211 0
46
4124 0
47
4221 0
48
43212 0
49
4438 0
50
453111
51
46314 0
52
473141
53
48311 0
54
4943 0
55
50413 0
56
51492
57
524172
58
53415 0
59
5442 0
60
554141
61
5648 0
62
5746 0
63
58417 0
64
;
2 Code Block
PROC LOGISTIC
Explanation : PROC LOGISTIC is used to fit a logistic regression model. The 'model y/n' clause indicates a binomial response variable where 'y' is the number of 'successes' and 'n' is the total number of trials. Variables z2, z3, and z4 are the predictors. The 'scale=none' option is specified to prevent automatic scale adjustment, which is relevant when examining overdispersion.
Copied!
proc logistic;
model y/n = z2 z3 z4 / scale=none;
1
2
PROC LOGISTIC;
3
4
model y/n = z2 z3 z4 / scale=none;
5
3 Code Block
PROC NLMIXED
Explanation : PROC NLMIXED is used to fit a nonlinear mixed model. The 'qpoints=30' option specifies the number of quadrature points for numerical integration. The 'eta' and 'p' equations define the linear part and the probability (via the inverse logit function) of the model. The 'model y ~ binomial(n,p)' clause specifies that 'y' follows a binomial distribution with 'n' trials and a probability 'p'. A random effect 'u' is included and assumed to follow a normal distribution with a mean of 0 and a variance 'sigma*sigma', grouped by 'litter', which allows modeling overdispersion by accounting for variability between litters.
Copied!
proc nlmixed qpoints=30;
eta = alpha + beta2*z2 + beta3*z3 + beta4*z4 + u ;
p = exp(eta)/(1 + exp(eta));
model y ~ binomial(n,p) ;
random u ~ normal(0, sigma*sigma) subject=litter;
run;
1
PROC NLMIXED qpoints=30;
2
eta = alpha + beta2*z2 + beta3*z3 + beta4*z4 + u ;
3
p = exp(eta)/(1 + exp(eta));
4
model y ~ binomial(n,p) ;
5
random u ~ normal(0, sigma*sigma) subject=litter;
6
RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.