I am trying to covert the following R code to SAS IML LDA<-function(I,r,x,n) { total<-sum(r*x) options(warn=-1) lik<-function(phi) { -sum(-r*phi*x+(n-r)*log(1-exp(-phi*x))) } #Maximizing phi actual=optim(0.5,lik)$par if ((1/actual)>x[I]) { u=cat(as.integer(1/actual)," ",paste("Warning:Estimate exceeds maximum cells tested per well"),"\n") } else { u=(as.integer(1/actual)) } print(paste("Estimated from LDA")) return(c(u,total)) } For the following test data I<-9 r<-c(0, 0, 0, 6, 8, 8, 8, 8, 😎 x<-c(50000, 10000, 2000, 400, 80, 16, 3.2, 0.64, 0.128) n<-c(8, 8, 8, 8, 8, 8, 8, 8, 😎 LDA(I,r,x,n) The result is 871 and 3199.744. Here is my IML code. proc iml; I=9; r={0, 0, 0, 6, 8, 8, 8, 8, 8}; x={50000, 10000, 2000, 400, 80, 16, 3.2, 0.64, 0.128}; n={8, 8, 8, 8, 8, 8, 8, 8, 8}; total=sum(r#x); print I, r, x, n, total; start lik(phi) global(r, x, n); f=sum(-r#phi#x+(n-r)#log(1-exp(-phi#x))); return(f); finish lik; phi={0.5}; optn={1, 4, 10}; con={0.0000000001, .}; parm={.,0.1}; call nlpnms(rc, result, "lik", phi, optn, con, , parm); u=round(1/result,1); if u>x[1] then print "Warning: Estimate exceeds maximum cells tested per well"; print u, total; quit; The result I got is 876 and 3199.744. What do I need to do in the IML code in order to get the same result as R code? Thanks, JJ
... View more