The assignment I'm working on is to code from scratch a medthod to use commingling analysis methods to maximize a likelihood equation for a biallelic SNP. I am only given the phenotypes and am attemping to do a grid search method to find the parameters (mu1, mu2, mu3, q, and std.dev.) as well as the Log Lilkihood to run a LR test. When I look at 20-50 observations, it seems that my program is not running through any of the variables other than mu1. Does anyone have a suggestion on how to fix it? I've been playing around with different options and can't seem to find a solution. Thanks! %Macro likelihood(qstep,mu1step,mu2step,mu3step); data likely; set onet; *transposed data set for horizontal array; array aQTp (200) COL1-COL200; array MLE (200) MLE1-MLE200; do q=0.0 to 0.5 by &qstep; do mu1=&trtmin to &trtmax by &mu1step; do mu2=&trtmin to &trtmax by &mu2step; do mu3=&trtmin to &trtmax by &mu3step; do sd=&sdmin to &sdmax by &sdstep; do i=1 to 200; MLE(i)=log(((1-q)**2)*(1/sqrt(2*CONSTANT('PI')*sd))*(EXP((-0.5)*((aQTp(i)-mu1)/sd)**2))+(2*q*(1-q))*(1/sqrt(2*CONSTANT('PI')*sd))*(EXP((-0.5)*((aQTp(i)-mu2)/sd)**2))+(q**2)*(1/sqrt(2*CONSTANT('PI')*sd))*(EXP((-0.5)*((aQTp(i)-mu3)/sd)**2))); If MLE(i) =. then MLE(i)=0; end; *End of QTp Loop; logMLEtot=0; LogMLEtot=sum(of MLE1-MLE200); output; end; *End of SD Loop; end; *End of Mu3 Loop; end; *End of Mu2 Loop; end; *End of Mu1 Loop; end; *End of q Loop; Run; [... Deleted Code to Check Work and Create Macro Variable Below] %Let MLEtotmax=&MLEtotmax; Proc sort data=likely; by DESCENDING logMLEtot; run; Data likely; set likely; keep mu1 mu2 mu3 sd q logMLEtot; run; PRoc print data=likely (obs=10); run %MEND likelihood; %liklihood(0.01,0.01,0.01,0.01) Run;

... View more