Published on :
Statistical INTERNAL_CREATION

Documentation Example 4 for PROC NLMIXED

This code is also available in: Deutsch Español Français
Awaiting validation
This script illustrates the use of the NLMIXED procedure to fit a Poisson-Normal model to count data. It begins by creating an internal dataset named 'pump' which contains variables 'y', 't', and 'group', as well as derived variables 'pump' and 'logtstd'. Then, the NLMIXED procedure is called with this dataset to estimate the parameters of a nonlinear mixed-effects model. The model includes fixed parameters (beta1, beta2, alpha1, alpha2) and a random effect (e) normally distributed, with variance modeled by logsig. Contrast estimates are also requested.
Data Analysis

Type : INTERNAL_CREATION


The 'pump' dataset is created directly within the SAS script using the DATALINES statement, meaning the data is embedded and internally generated for script execution.

1 Code Block
DATA STEP Data
Explanation :
This DATA STEP block creates the 'pump' dataset. It reads the variables 'y', 't', and 'group' from the embedded data (datalines). It also creates a 'pump' variable which is a unique identifier for each observation (_n_), and 'logtstd' which is the standardized logarithmic transformation of 't'.
Copied!
1DATA pump;
2 INPUT y t group;
3 pump = _n_;
4 logtstd = log(t) - 2.4564900;
5 DATALINES;
6 5 94.320 1
7 1 15.720 2
8 5 62.880 1
914 125.760 1
10 3 5.240 2
1119 31.440 1
12 1 1.048 2
13 1 1.048 2
14 4 2.096 2
1522 10.480 2
16;
2 Code Block
PROC NLMIXED
Explanation :
This block uses PROC NLMIXED to fit a nonlinear mixed-effects model. It declares the model parameters (logsig, beta1, beta2, alpha1, alpha2) with their initial values. The 'eta' variable is defined differently depending on the value of 'group'. 'lambda' is the exponential transformation of 'eta'. The model assumes that 'y' follows a Poisson distribution with the 'lambda' parameter. A random effect 'e' is included, following a normal distribution with variance modeled by 'exp(2*logsig)', and is specified by 'subject=pump'. Finally, contrast estimates between the 'alpha' and 'beta' parameters of the two groups are calculated.
Copied!
1PROC NLMIXED DATA=pump;
2 parms logsig 0 beta1 1 beta2 1 alpha1 1 alpha2 1;
3 IF (group = 1) THEN eta = alpha1 + beta1*logtstd + e;
4 ELSE eta = alpha2 + beta2*logtstd + e;
5 lambda = exp(eta);
6 model y ~ poisson(lambda);
7 random e ~ normal(0,exp(2*logsig)) subject=pump;
8 estimate 'alpha1-alpha2' alpha1-alpha2;
9 estimate 'beta1-beta2' beta1-beta2;
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; NAME: nlmex4; TITLE: Documentation Example 4 for PROC NLMIXED; PRODUCT: STAT