```Date: Thu, 9 Dec 2010 15:20:29 -0800 Reply-To: Dale McLerran Sender: "SAS(r) Discussion" From: Dale McLerran Subject: Re: Nonlinear Model with Random Effects Comments: To: Phil Townsend Content-Type: text/plain; charset=us-ascii Phil, If you wish to allow an asymptote^=1, then the following code could be employed: proc nlmixed data=mydata; /* The following PARMS statement initializes the residual */ /* variance to 1 (=exp(0)), the variances of the random */ /* effects u1 and u2 to 0.05 (=exp(-3)), and the */ /* covariance of the random effects to 0. */ parms log_sigma 0 log_sigu0 log_sigu1 log_sigu2 -3 Z01 Z02 Z12 0; /* Construct the linear predictor including */ /* random effects u1 and u2. */ eta = c + u1 + (d + u2)*X; /* Formulas for the expected value and variance of Y */ mu = exp(log_b + u0) / (1 + exp(-eta)); V = exp(2*log_sigma); /* Correlation of the random effects */ rho01 = (exp(2*Z01) - 1) / (exp(2*Z01) + 1); rho02 = (exp(2*Z02) - 1) / (exp(2*Z02) + 1); rho12 = (exp(2*Z12) - 1) / (exp(2*Z12) + 1); /* Fit the nonlinear random effects model */ model Y ~ normal(mu, V); random u0 u1 u2 ~ normal([0,0,0], [exp(2*log_sigu0), rho01*exp(log_sigu0 + log_sigu1), exp(2*log_sigu1), rho02*exp(log_sigu0 + log_sigu2), rho12*exp(log_sigu1 + log_sigu2), exp(2*log_sigu2)]) subject=year; /* Generate additional estimates of interest */ estimate "Asymptote" exp(log_b); estimate "V(resid)" V; estimate "V(u0)" exp(2*log_sigu0); estimate "V(u1)" exp(2*log_sigu1); estimate "V(u2)" exp(2*log_sigu2); estimate "rho(u0,u1)" rho01; estimate "rho(u0,u2)" rho02; estimate "rho(u1,u2)" rho12; estimate "Cov(u0,u1)" rho*exp(log_sigu0 + log_sigu1); estimate "Cov(u0,u2)" rho*exp(log_sigu0 + log_sigu2); estimate "Cov(u1,u2)" rho*exp(log_sigu1 + log_sigu2); run; With the addition of another random effect, we have to estimate a random effects covariance structure which has 6 terms instead of three terms. Previously, we had the variances of the two random effects along with their correlation. With three random effects, we have three variances and three correlations to estimate. It should be noted that there is no guarantee that the covariance matrix parameterized as I have it is positive-(semi)definite. One could estimate the parameters of a Cholesky decomposition of the covariance matrix. That would guarantee that the covariance matrix was p.d. But the above coding is a bit easier to construct than the Cholesky decomposition coding of the covariance matrix. You may have noticed that I wrote that asymptote as exp(log_b + u0). By parameterizing the asymptote like this, we guarantee a positive value for the asymptote for every response. Dale --------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@NO_SPAMfhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 --------------------------------------- --- On Thu, 12/9/10, Phil Townsend wrote: From: Phil Townsend Subject: Re: [SAS-L] Nonlinear Model with Random Effects To: "Dale McLerran" Cc: SAS-L@listserv.uga.edu Date: Thursday, December 9, 2010, 1:06 PM Thank you. So how would I formulate the below model if I wanted to estimate 3 random effects, adding a third variable to the numerator, i.e. Y = b / (1 + exp(c + d*X)) This, estimating u3 (b+u3) in the random statement as well. Thanks again,Phil ```

Back to: Top of message | Previous page | Main SAS-L page