Published on :
Statistics CREATION_INTERNE

Analysis of Overdispersion in Teratology

This code is also available in: Deutsch Español Français
Awaiting validation
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.
Copied!
1DATA teratology;
2 INPUT litter group n y ;
3 z2=0; z3=0; z4=0;
4 IF group=2 THEN z2=1; IF group=3 THEN z3=1; IF group=4 THEN z4=1;
5CARDS;
6 1 1 10 1
7 2 1 11 4
8 3 1 12 9
9 4 1 4 4
10 5 1 10 10
11 6 1 11 9
12 7 1 9 9
13 8 1 11 11
14 9 1 10 10
15 10 1 10 7
16 11 1 12 12
17 12 1 10 9
18 13 1 8 8
19 14 1 11 9
20 15 1 6 4
21 16 1 9 7
22 17 1 14 14
23 18 1 12 7
24 19 1 11 9
25 20 1 13 8
26 21 1 14 5
27 22 1 10 10
28 23 1 12 10
29 24 1 13 8
30 25 1 10 10
31 26 1 14 3
32 27 1 13 13
33 28 1 4 3
34 29 1 8 8
35 30 1 13 5
36 31 1 12 12
37 32 2 10 1
38 33 2 3 1
39 34 2 13 1
40 35 2 12 0
41 36 2 14 4
42 37 2 9 2
43 38 2 13 2
44 39 2 16 1
45 40 2 11 0
46 41 2 4 0
47 42 2 1 0
48 43 2 12 0
49 44 3 8 0
50 45 3 11 1
51 46 3 14 0
52 47 3 14 1
53 48 3 11 0
54 49 4 3 0
55 50 4 13 0
56 51 4 9 2
57 52 4 17 2
58 53 4 15 0
59 54 4 2 0
60 55 4 14 1
61 56 4 8 0
62 57 4 6 0
63 58 4 17 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!
1 
2PROC LOGISTIC;
3 
4model 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!
1PROC 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;
6RUN;
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.