Published on :
Statistical INTERNAL_CREATION

PROC NLMIXED Getting Started Example 2

This code is also available in: Deutsch Español Français
Awaiting validation
This SAS© script is the second getting started example for using PROC NLMIXED. It implements a logistic-normal model to analyze binomial data from a multicenter clinical trial, as described by Beitler and Landis (1985). It demonstrates the specification of parameters, fixed and random effects, and the prediction of inter-clinic heterogeneity.
Data Analysis

Type : INTERNAL_CREATION


The 'infection' data is created directly within the SAS script using a DATALINES block. It includes the variables clinic, t, x, and n, representing information from a clinical trial.

1 Code Block
DATA STEP Data
Explanation :
This DATA STEP block creates the 'infection' dataset using embedded raw data (DATALINES). Each row represents an observation with the variables clinic (clinic identifier), t (treatment), x (number of successes), and n (total number of trials).
Copied!
1DATA infection;
2 INPUT clinic t x n;
3 DATALINES;
41 1 11 36
51 0 10 37
62 1 16 20
72 0 22 32
83 1 14 19
93 0 7 19
104 1 2 16
114 0 1 17
125 1 6 17
135 0 0 12
146 1 1 11
156 0 0 10
167 1 1 5
177 0 1 9
188 1 4 6
198 0 6 7
20;
2 Code Block
PROC NLMIXED
Explanation :
This PROC NLMIXED procedure fits a logistic mixed-effects model to the 'infection' data.
- `parms` initializes the model parameters: `beta0` (intercept), `beta1` (effect of treatment 't'), and `s2u` (variance of the random effect).
- `eta`, `expeta`, and `p` define the linear predictor part (`eta`) and the probability of success (`p`) according to a logistic model.
- `model x ~ binomial(n,p)` specifies that the variable `x` (number of successes) follows a binomial distribution with `n` trials and probability `p`.
- `random u ~ normal(0,s2u) subject=clinic` introduces a random effect `u` for each `clinic`, assumed to follow a normal distribution with a mean of 0 and variance `s2u`. This allows modeling heterogeneity between clinics.
- `predict eta out=eta` calculates and outputs the predicted values for `eta`.
- `estimate '1/beta1' 1/beta1` requests an estimate of the inverse of the `beta1` parameter.
Copied!
1PROC NLMIXED DATA=infection;
2 parms beta0=-1 beta1=1 s2u=2;
3 eta = beta0 + beta1*t + u;
4 expeta = exp(eta);
5 p = expeta/(1+expeta);
6 model x ~ binomial(n,p);
7 random u ~ normal(0,s2u) subject=clinic;
8 predict eta out=eta;
9 estimate '1/beta1' 1/beta1;
10RUN;
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.
Copyright Info : S A S S A M P L E L I B R A R Y