Date: Mon, 22 Nov 2010 14:42:25 -0200
Reply-To: Ricardo Gonçalves da Silva
<rgs.rsilva@BANCOVOTORANTIM.COM.BR>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ricardo Gonçalves da Silva
<rgs.rsilva@BANCOVOTORANTIM.COM.BR>
Subject: RES: NLMIXED Output combinations
In-Reply-To: <448371.6881.qm@web32405.mail.mud.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"
Sorry, I forgot to reply to the list.
Hi Dale,
In fact, what I want is the value of the log-likelihood for each iteration.
The simulated data refers to a systematic factor, which enters in my model as a N(0,1) variate.
Concerning the trick you set, I can include it directly into the PARMS statement?
Finally, if you could help me even more, I'm using the PROC NLMIXED in order to replicate the code below, wich I developed. The problem is that the code takes 11 hours to run, and the PROC, just a few minutes. The reference for the model is the section 4.6, pg 15, of the paper you can found in http://www.crc.man.ed.ac.uk/conference/archive/2005/papers/forest-alan.pdf . The difference is that I add one more grade.
Regards,
Rick
Original Code:
DATA LIKELIHOOD;
RETAIN N_A 23 N_B 54 N_C 170 R 0.15 LOW_DEF 0 MED_DEF 1 HIG_DEF 2 RHO 0.12;
N_P = N_A + N_B + N_C;
M_A = N_A/N_P;
M_B = N_B/N_P;
M_C = N_C/N_P;
NAMLOWDEF=N_A-LOW_DEF;
NBMMEDDEF=N_B-MED_DEF;
NCMHIGDEF=N_C-HIG_DEF;
ONEMR=1-R;
ONEMRINV=ONEMR**(-0.5);
RRATIO=R/ONEMR;
RRATIOSQRT=RRATIO**0.5;
PROBIT999=PROBIT(0.999);
RRPROB999=RRATIOSQRT*PROBIT999;
ONEMRHO=1-RHO;
RHORATIO=RHO/ONEMRHO;
RHORATIOSQRT=SQRT(RHORATIO);
DO A = 0 TO 0.5 BY 0.002;
LA=LOG(A);
LA1=LOG(1-A);
APROBIT=PROBIT(A);
K_LOW = PROBNORM(ONEMRINV*APROBIT + RRPROB999) - A;
MAKLOW=M_A*K_LOW;
DO B = 0 TO 0.5 BY 0.002;
LB=LOG(B);
LB1=LOG(1-B);
BPROBIT=PROBIT(B);
K_MED = PROBNORM(ONEMRINV*BPROBIT + RRPROB999) - B;
MBKSUM=SUM(MAKLOW,M_B*K_MED);
DO C = 0 TO 0.5 BY 0.002;
LC = LOG(C);
LC1= LOG(1-C);
CPROBIT=PROBIT(C);
K_HIG = PROBNORM(ONEMRINV*CPROBIT + RRPROB999) - C;
K_ALL = SUM(MBKSUM,M_C*K_HIG);
PD = 0;
ARRAY PROBITS{3} APROBIT BPROBIT CPROBIT;
ARRAY DASHX{3} A_X B_X C_X;
ARRAY ABC{3} A B C;
ARRAY ONEMDASHX{3} ONEMA_X ONEMB_X ONEMC_X;
DO x = 0.0005 TO 1 BY .0005;
XPROBIT=PROBIT(X);
DO I=1 TO 3;
ARGUMENT = (PROBITS{I} + XPROBIT*RHORATIOSQRT);
DASHX{I}= CDF('NORMAL',ARGUMENT,0,1);
IF (DASHX{I} EQ .) THEN DASHX{I} = ABC{I};
ONEMDASHX{I}=1-DASHX{I};
END;
PD = SUM(PD , ((ONEMA_X)**(NAMLOWDEF))*(A_X**LOW_DEF)*((ONEMB_X)**(NBMMEDDEF))*(B_X**MED_DEF)*
((ONEMC_X)**(NCMHIGDEF))*(C_X**HIG_DEF));
END;
PD = PD/2000;
LPD = LOG(PD);
OUTPUT;
END;
END;
END;
KEEP A B C LOW_DEF MED_DEF HIG_DEF K_ALL LPD; RUN;
-----Mensagem original-----
De: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] Em nome de Dale McLerran
Enviada em: Tuesday, November 16, 2010 6:16 PM
Para: SAS-L@LISTSERV.UGA.EDU
Assunto: Re: NLMIXED Output combinations
Rick,
I don't understand the first part of your problem. You indicate
that you want a table of "every parameter estimates, i.e. for
every Y". Can you provide a small example of the output that you
would like to obtain?
Also, I have to ask about your simulated data. The value of Y
does not depend on any other terms (rho, D1, D2, D3, N1, N2, N3).
What is your simulated data supposed to show? Would you please
clarify?
As far as constructing parameters P, Q, and R such that
0<=P<=Q<=R<=1, I don't believe that you can do so with a BOUNDS
statement. I dislike BOUNDS statements anyway because
derivatives are not defined on the boundary. You could construct
P, Q, and R subject to the constraints that you have specified,
but you have to get a little tricky to do so.
Let's start with the parameter P. We will construct P as a
function of a parameter _P where _P is a real valued parameter
whose range is -infinity to infinity.
P = (1 + (exp(_P) - 1)/(exp(_P) + 1) ) / 2;
Note that when _P -> -infinity, exp(_P) -> 0 and
P = (1 + (0-1)/(0+1) ) / 2 = (1 + -1)/2 = 0, _P -> -infinity
When _P -> infinity, the ratio (exp(_P) - 1)/(exp(_P) + 1) -> 1
and
P = (1 + 1) / 2 = 1, _P -> infinity
So, the range of P is (0,1) for our parameter _P which has domain
(-infinity, infinity).
A similar function can be employed to construct Q and R such that
P<=Q and Q<=R. If we add a non-negative term Q' to _P, such that
we have Q* = _P + Q', and if we compute
Q = (1 + (exp(Q*) - 1)/(exp(Q*) + 1) ) / 2;
then Q will have range (P,1). Let Q'=exp(_Q). Without restriction
on the parameter space, _Q has domain -infinity to infinity, but
Q' has range (0,infinity). Programatically, we could write
Qstar = _P + exp(_Q);
Q = (1 + (exp(Qstar) - 1)/(exp(Qstar) + 1) ) / 2;
The extension to constructing R satisfying the conditions stated
above would be to let R* = _P + Q' + R' with R'>0 provided by
letting R'=exp(_R). Thus, we would have
Rstar = _P + exp(_Q) + exp(_R);
R = (1 + (exp(Rstar) - 1)/(exp(Rstar) + 1) ) / 2;
HTH,
Dale
---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center
mailto: dmclerra@NO_SPAMfhcrc.org
Ph: (206) 667-2926
Fax: (206) 667-5977
---------------------------------------
--- On Tue, 11/16/10, Ricardo Gonçalves da Silva <rgs.rsilva@BANCOVOTORANTIM.COM.BR> wrote:
> From: Ricardo Gonçalves da Silva <rgs.rsilva@BANCOVOTORANTIM.COM.BR>
> Subject: NLMIXED Output combinations
> To: SAS-L@LISTSERV.UGA.EDU
> Date: Tuesday, November 16, 2010, 9:14 AM
> Hi,
>
> In the following code, how I ask SAS to give me a table
> with every parameters estimates, i.e., for every Y?
> In fact, I want to restrict the parameters in order P le Q
> le R.
>
> DATA CORP_09;
> DO I=1 TO 100000;
> Y=RANNOR(125);
> OUTPUT;
> RHO=0.12;
> N1=20;
> D1=1;
> N2=52;
> D2=1;
> N3=151;
> D3=5;
> END;
> RUN;
> PROC NLMIXED DATA=CORP_09;
> BOUNDS 0 <= P Q R <=1;
> PARMS P=0.0000005 Q=0.0000005 R=0.0000005;
> NUM1 = (PROBIT(P)+Y*SQRT(RHO))/SQRT(1-RHO);
> NUM2 = (PROBIT(Q)+Y*SQRT(RHO))/SQRT(1-RHO);
> NUM3 = (PROBIT(R)+Y*SQRT(RHO))/SQRT(1-RHO);
> LOGLIKE = D1*LOG(PROBNORM(NUM1)) +
> (N1-D1)*LOG(1-PROBNORM(NUM1))
> + D2*LOG(PROBNORM(NUM2)) + (N2-D2)*LOG(1-PROBNORM(NUM2))
> + D3*LOG(PROBNORM(NUM3)) + (N3-D3)*LOG(1-PROBNORM(NUM3));
> MODEL Y~GENERAL(LOGLIKE) ;
> RUN;
>
> Thanks
>
> Rick
>
>
> Esta mensagem e seus anexos podem conter informações
> confidenciais ou privilegiadas. Se você não é o
> destinatário dos mesmos você não está autorizado a
> utilizar o material para qualquer fim. Solicitamos que você
> apague a mensagem e avise imediatamente ao remetente. O
> conteúdo desta mensagem e seus anexos não representam
> necessariamente a opinião e a intenção da empresa, não
> implicando em qualquer obrigaçâo ou responsabilidade da
> parte da mesma.
> This message may contain confidential and/or privileged
> information. If you are not the addressee or authorized to
> receive this for the addressee, you must not use, copy,
> disclose or take any action based on this message or any
> information herein. If you have received this message in
> error, please advise the sender immediately by reply e-mail
> and delete this message. The contents of this message and
> its attachments do not necessarily express the opinion or
> the intention of the company, and do not implies any legal
> obligation or responsibilities from this
> company.
>
Esta mensagem e seus anexos podem conter informações confidenciais ou privilegiadas. Se você não é o destinatário dos mesmos você não está autorizado a utilizar o material para qualquer fim. Solicitamos que você apague a mensagem e avise imediatamente ao remetente. O conteúdo desta mensagem e seus anexos não representam necessariamente a opinião e a intenção da empresa, não implicando em qualquer obrigaçâo ou responsabilidade da parte da mesma.
This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. The contents of this message and its attachments do not necessarily express the opinion or the intention of the company, and do not implies any legal obligation or responsibilities from this company.
|