Hi, When I run the nlmixed model, I keep getting warning like this NOTE: By default, formatted unique SUBJECT= variable values are used. In releases prior to SAS/STAT 13.1, by default, SUBJECT= variable values were not examined for uniqueness. To revert to the previous behavior, specify the NOSORTSUB option in the PROC NLMIXED statement. NOTE: Convergence criterion (GCONV=1E-8) satisfied. NOTE: At least one element of the gradient is greater than 1e-3. NOTE: Execution error while processing ESTIMATE statement. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.DATA1 may be incomplete. When this step was stopped there were 382068 observations and 33 variables. WARNING: Data set WORK.DATA1 was not replaced because this step was stopped. WARNING: The data set WORK.DATA2 may be incomplete. When this step was stopped there were 382068 observations and 33 variables. WARNING: Data set WORK.DATA2 was not replaced because this step was stopped. Here is the code: %macro focalvar (focalvar); proc nlmixed data=base qpoints=5; /* define initial values and bounds */ parms alpha0=-1 alpha1=1 alpha2=1 alpha3=1 alpha4=1 alpha5=1 alpha6=1 alpha7=1 beta0=1 beta1=1 beta2=1 beta3=1 beta4=1 beta5=1 beta6=1 beta7=1 delta0=1 delta1=2 delta2=2 delta3=2 delta4=2 delta5=2 delta6=2 delta7=2 var1=1 var2=1 cov12=.5 k=2; bounds var1 var2 >=0; /* Part I log-likelihood */ teta=alpha0 + a + alpha1*during + alpha2*exposed2 + alpha3*during*exposed2+alpha4*&focalvar+alpha5*&focalvar*during+alpha6*&focalvar*exposed2+alpha7*&focalvar*during*exposed2; expteta=exp(teta); p=expteta/(1+expteta); if new_rate=0 then loglik=log(1-p); /* Part II log-likelihood */ if new_rate=1 then do; mu=beta0 + b + beta1*during + beta2*exposed2 + beta3*during*exposed2+beta4*&focalvar+beta5*&focalvar*during+beta6*&focalvar*exposed2+beta7*&focalvar*during*exposed2; /* Mean of gen. gamma dist. */ sigma=exp((delta0 + delta1*during + delta2*exposed2 + delta3*during*exposed2+delta4*&focalvar+delta5*&focalvar*during+delta6*&focalvar*exposed2+delta7*&focalvar*during*exposed2)/2); /* Scale of gen. gamma dist. */ eta=abs(k) ** (-2); u=sign(k)*(log(rate)-mu)/sigma; value1=eta *log (eta) - log(sigma) -.5 * log(eta) - lgamma(eta); loglik=log(p) + value1 + u *sqrt(eta) - eta * exp(abs(k)* u); end; /* fit the model above */ model rate ~ general(loglik); random a b ~ normal([0, 0], [var1, cov12, var2]) subject=household_key; /* generate empirical Bayes estimates for random effects and store them in SAS datasets data1 and data2; */ predict a out=data1; predict b out=data2; estimate '1' alpha1+log(1+exp(alpha0))-log(1+exp(alpha0+alpha1)) +beta1 + log(k**2)/k*( exp((delta0+delta1)/2)-exp(delta0/2) ) + log( gamma(1/k**2+exp((delta0+delta1)/2)/k) / gamma(1/k**2+exp(delta0/2)/k) ); estimate '2' alpha2+log(1+exp(alpha0))-log(1+exp(alpha0+alpha2)) +beta2 + log(k**2)/k*( exp((delta0+delta2)/2)-exp(delta0/2) ) + log( gamma(1/k**2+exp((delta0+delta2)/2)/k) / gamma(1/k**2+exp(delta0/2)/k) ); estimate '3' alpha3+log(1+exp(alpha0+alpha1+alpha2))-log(1+exp(alpha0+alpha1+alpha2+alpha3)) +beta3 + log(k**2)/k*( exp((delta0+delta1+delta2+delta3)/2)-exp((delta0+delta1+delta2)/2) ) + log( gamma(1/k**2+exp((delta0+delta1+delta2+delta3)/2)/k) / gamma(1/k**2+exp((delta0+delta1+delta2)/2)/k) ); estimate '4' alpha4+log(1+exp(alpha0))-log(1+exp(alpha0+alpha4)) +beta4 + log(k**2)/k*( exp((delta0+delta4)/2)-exp(delta0/2) ) + log( gamma(1/k**2+exp((delta0+delta4)/2)/k) / gamma(1/k**2+exp(delta0/2)/k) ); estimate '5' alpha5+log(1+exp(alpha0+alpha1+alpha4))-log(1+exp(alpha0+alpha1+alpha4+alpha5)) +beta5 + log(k**2)/k*( exp((delta0+delta1+delta4+delta5)/2)-exp((delta0+delta1+delta4)/2) ) + log( gamma(1/k**2+exp((delta0+delta1+delta4+delta5)/2)/k) / gamma(1/k**2+exp((delta0+delta1+delta4)/2)/k) ); estimate '6' alpha6+log(1+exp(alpha0+alpha2+alpha4))-log(1+exp(alpha0+alpha2+alpha4+alpha6)) +beta6 + log(k**2)/k*( exp((delta0+delta2+delta4+delta6)/2)-exp((delta0+delta2+delta4)/2) ) + log( gamma(1/k**2+exp((delta0+delta2+delta4+delta6)/2)/k) / gamma(1/k**2+exp((delta0+delta2+delta4)/2)/k) ); estimate '7' alpha7+log(1+exp(alpha0+alpha1+alpha2+alpha3+alpha4+alpha5+alpha6))-log(1+exp(alpha0+alpha1+alpha2+alpha3+alpha4+alpha5+alpha6+alpha7)) +beta7 + log(k**2)/k*( exp((delta0+delta1+delta2+delta3+delta4+delta5+delta6+delta7)/2)-exp((delta0+delta1+delta2+delta3+delta4+delta5+delta6)/2) ) + log( gamma(1/k**2+exp((delta0+delta1+delta2+delta4+delta7)/2)/k) / gamma(1/k**2+exp((delta0+delta1+delta2+delta3+delta4+delta5+delta6)/2)/k) ); %mend focalvar; %focalvar (cate1); %focalvar (cate2); %focalvar (cate3); %focalvar (cate4); %focalvar (cate5); %focalvar (cate6); %focalvar (cate7); %focalvar (cate8); run; Except for first two macros, others run successfully. It is so weird.... Thanks!!!!!
... View more