exponential function

Occasional Contributor
Posts: 15

exponential function

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:

---------------------------------------------------------------------

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;

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;

Occasional Contributor
Posts: 15

exponential function

Woops, I think the issue is that the values in my vector 'p' are too small. :smileysilly:

By the way, in IML, can we assign a value as scalar  instead to a (1x1) matrix?

Thank you

Elvin

Occasional Contributor
Posts: 17

exponential function

`telescopic wrote:  By the way, in IML, can we assign a value as scalar  instead to a (1x1) matrix?`

1x1 matrices are scalars

http://support.sas.com/documentation/cdl/en/imlug/64248/HTML/default/viewer.htm#imlug_languagechap_s...

The main problem with your programme above is that in your likelihood module the result of the calculation of EXP(194481) is too big for the computer to handle. I think you also want to pass rows of p as arguments to LogLik and not the whole matrix. I suppose you have seen Rick's recent blog post. If not, have a look at what he did:

http://blogs.sas.com/content/iml/2011/10/12/maximum-likelihood-estimation-in-sasiml/

SAS Super FREQ
Posts: 4,239

exponential function

By the way, you don't need the loop over all elements of Y.

start LogLik(param) global (Y);

lamda = param[1];

gamma = param[2];

f = sum( exp((-lamda*Y)##gamma) );

return ( f );

finish;

Discussion stats
• 3 replies
• 1349 views
• 0 likes
• 3 in conversation