Hi, I have problem on 'exp' function. Please see the bolded line in code.
a = exp( (-lamda*Y)**gamma ) ;
where gamma and lamda is (1x1) matrix or scalar. Without "exp", The routine return the value f. But, adding 'exp', it returns error!
Error message-----------------------------------------------------------------
ERROR: (execution) Invalid argument to function.
operation : EXP at line 925 column 12
operands : _TEM1004
_TEM1004 1 row 1 col (numeric)
194481
statement : ASSIGN at line 925 column 5
traceback : module LOGLIK at line 925 column 5
---------------------------------------------------------------------------
I cannot see the reason. Maybe it is due to issue on applying function elementwise versus on a matrix?
Thank you
Elvin
CODE:
---------------------------------------------------------------------
Data radiotherapy;
input y age gender $ censor_ind;
datalines;
7 68 f 1
9 69 f 1
12 68 f 1
12 71 f 1
19 77 m 1
23 70 f 1
;
RUN;
PROC IML;
RESET LOG PRINT;
USE radiotherapy VAR _ALL_;
READ all VAR{y} INTO Y;
READ all VAR{age} INTO AGE;
READ all VAR{gender} INTO GENDER;
READ all VAR{censor_ind} INTO CENSOR_IND;
CLOSE radiotherapy;
start LogLik(param) global (Y);
lamda = param[1];
gamma = param[2];
n = nrow(Y);
f=0;
DO i=1 to nrow(Y);
a = exp( (-lamda*Y)**gamma ) ;
f=f+a;
END;
return ( f );
finish;
p={3 4, 6 9};
ans=LogLik(p);
quit;