Skip to content

Instantly share code, notes, and snippets.

@MJacobs1985
Created September 29, 2021 19:29
Show Gist options
  • Save MJacobs1985/da2949254c6032b639d667da96fb9eb2 to your computer and use it in GitHub Desktop.
Save MJacobs1985/da2949254c6032b639d667da96fb9eb2 to your computer and use it in GitHub Desktop.
Simulations in SAS
data IB;
do sim=1;
do dose=0,20,40,60,80,100,160 ;
do pen=1 to 100;
if dose=0 then Y=200 + rand("Normal", 0, sqrt(480.779));
if dose=20 then Y=304 + rand("Normal", 0, sqrt(480.779));
if dose=40 then Y=317 + rand("Normal", 0, sqrt(480.779));
if dose=60 then Y=321 + rand("Normal", 0, sqrt(480.779));
if dose=80 then Y=326 + rand("Normal", 0, sqrt(480.779));
if dose=100 then Y=332 + rand("Normal", 0, sqrt(480.779));
if dose=160 then Y=332 + rand("Normal", 0, sqrt(480.779)); /* 332 is assumption */
output;
end;
end;
end;
run;
proc nlin data=IB plots=all maxiter=20 hougaard nlinmeasures bias;
where sim=1;
parms a=314 k=0.06 T=-15;
model Y=a*exp(-exp(-k*(Dose-T)));
output out=IBpred p=yhat r=resid student=stresid lcl=lpl lclm=lcl ucl=upl uclm=ucl parms=a k T;
run; /* a=347 / k=0.00975 / T=-205.4 */
proc sgplot data=IBpred;
scatter y=Y x=dose;
series y=yhat x=dose / name="fit" lineattrs=(color=red pattern=2) LegendLabel="Predicted";
series y=lpl x=dose / lineattrs=GraphConfidence name="lpl" legendlabel="95% Prediction limits";
series y=upl x=dose / lineattrs=GraphConfidence;
band x=dose lower=lcl upper=ucl / fillattrs=(color=red) name="lcl" legendlabel="95% Confidence limits" transparency=0.75;
refline k / axis=x lineattrs=(color=orange pattern=2) label="Inflection Point" labelpos=max labelloc=outside labelattrs=(color=orange) ;
refline a / axis=y lineattrs=(color=green pattern=2) label="Asymptot" labelpos=max labelloc=inside labelattrs=(color=green);
keylegend "fit" "lpl" "lcl";
yaxis label="Y ";
xaxis label="Day ";
Title "Gompertz to describe Y ";
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment