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'.
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!
proc nlmixed data=pump;
parms logsig 0 beta1 1 beta2 1 alpha1 1 alpha2 1;
if (group = 1) then eta = alpha1 + beta1*logtstd + e;
else eta = alpha2 + beta2*logtstd + e;
lambda = exp(eta);
model y ~ poisson(lambda);
random e ~ normal(0,exp(2*logsig)) subject=pump;
estimate 'alpha1-alpha2' alpha1-alpha2;
estimate 'beta1-beta2' beta1-beta2;
run;
1
PROC NLMIXEDDATA=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;
10
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.
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
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.