n******0 发帖数: 298 | 1 麻烦那位大牛帮看一看,谢谢。
我想用PROC IML里的subroutine求exponential duration model 的MLE,这是我的CODE
,得到的error message是"ERROR: (execution) Matrix has not been set to a
value.",到底是哪儿的问题?exp是读入的data set,t是random numbers generated
from an exponential distribution.
%macro test(dsn=,x=);
proc iml;
reset noname;
use &dsn;
read all var {&x} into tt;
print tt;
start LL(beta);
f=sum(log(beta)-beta#tt);
return(f);
finish LL;
start grad(beta);
g=j(1,1,0);
g=sum(1/beta-tt);
return(g);
finish grad;
start hess(beta);
h=j(1,1,0); |
h****s 发帖数: 16779 | 2 这个use 没有close,先试试是不是这个错。
use &dsn;
read all var {&x} into tt;
print tt; |
n******0 发帖数: 298 | 3 加了CLOSE,没用。
【在 h****s 的大作中提到】 : 这个use 没有close,先试试是不是这个错。 : use &dsn; : read all var {&x} into tt; : print tt;
|
h****s 发帖数: 16779 | |
h****s 发帖数: 16779 | 5 LL 和 grad module里面的tt没定义,改成这个:
start LL(beta) global (tt);
f=sum(log(beta)-beta#tt);
return(f);
finish LL;
start grad(beta) global (tt);
g=j(1,1,0);
g=sum(1/beta-tt);
return(g);
finish grad; |
n******0 发帖数: 298 | 6 I thought about the same thing. It still didn't work after I added global (
tt).
Thanks.
【在 h****s 的大作中提到】 : LL 和 grad module里面的tt没定义,改成这个: : start LL(beta) global (tt); : f=sum(log(beta)-beta#tt); : return(f); : finish LL; : start grad(beta) global (tt); : g=j(1,1,0); : g=sum(1/beta-tt); : return(g); : finish grad;
|
h****s 发帖数: 16779 | 7 I tried and it now works well: maybe you can check your data.
【在 n******0 的大作中提到】 : I thought about the same thing. It still didn't work after I added global ( : tt). : Thanks.
|
n******0 发帖数: 298 | 8 Now I get "ERROR: (execution) Invalid argument to function."
Could you please post your code? Thanks so much for taking the time.
【在 h****s 的大作中提到】 : I tried and it now works well: maybe you can check your data.
|
n******0 发帖数: 298 | 9 This is my data. There are 100 observations in the data set.
data exp;
input t @@;
datalines;
0.46008226 0.41727405 0.20728763 0.49158278 0.05372043 0.74767695 0.
11532318 0.59817944 0.28878044 0.34212305
...........
;
run; |
j*****e 发帖数: 182 | 10 check this line:
g=sum(1/beta-tt);
Isn't beta a scalor, but tt is a column vector. Will"-" work here? |
|
|
n******0 发帖数: 298 | 11 It works.
【在 j*****e 的大作中提到】 : check this line: : g=sum(1/beta-tt); : Isn't beta a scalor, but tt is a column vector. Will"-" work here?
|
j*****e 发帖数: 182 | 12 Did you define the demension of f? |
n******0 发帖数: 298 | 13 i don't think it is necessary. f should be a scalar.
【在 j*****e 的大作中提到】 : Did you define the demension of f?
|
j*****e 发帖数: 182 | 14 Remove the macro statement. Just use IML.
Which line did SAS indicate that error?
Also,Add a boundary to beta(beta>0?) |
n******0 发帖数: 298 | 15 You are right, thanks.
【在 j*****e 的大作中提到】 : Remove the macro statement. Just use IML. : Which line did SAS indicate that error? : Also,Add a boundary to beta(beta>0?)
|