Dear all,
I have the following code that aims at maximixing LL_all with respect to "gidraw" which is scalar.
%the data
n=1;
Xfi=[ -1.4+randn(n,1) 0.5+0.6*randn(n,1)];
beta=[3 2 ]';
yi=randn(n) ;
gidraw=0.5;
lam=Xfi*beta + gidraw;
int=yi.*lam-exp(lam);
int=sum(int);
%the function
LL_all = -(log(normpdf(gidraw,2,sqrt(0.5)))+int);
So, my question is what is the maximum of LL_all? That is, how can I find the maximum of this function? Also can I calculate the Hessian matrix(which is a scalar more precisely) of this function?
Thanks in advance

댓글 수: 4

John D'Errico
John D'Errico 2015년 8월 17일
Well, first, you would need to define what gidraw is.
ektor
ektor 2015년 8월 18일
편집: ektor 2015년 8월 18일
thanks John. gidraw is a scalar. For example gidraw=0.5 (see above).
Walter Roberson
Walter Roberson 2015년 8월 19일
I thought I understood what you wanted, but lam is an n x 1 vector and yi is an n x n array, so yi .* lam is an error. yi*lam would be well defined and would be n x 1 which would be fine for adding exp(lam) which would be n x 1 as well. The sum() in the next line would then be creating a scalar. Is that what is desired?
ektor
ektor 2015년 8월 19일
편집: ektor 2015년 8월 19일
Hi Walter, I made a small modification in the above code to make things easier. n=10 now becomes n=1. Yes, this is what is desired. Basically I want to find the posterior mode of LL_all.

댓글을 달려면 로그인하십시오.

 채택된 답변

JMP Phillips
JMP Phillips 2015년 8월 19일

0 개 추천

If gidraw is a scalar, your problem doesn't make sense, as LL_all is just a number. If gidraw is vector, the maximum of -[log(normpdf) + int] is +Inf.

댓글 수: 2

ektor
ektor 2015년 8월 19일
Hi JMP, Thanks. I made a small modification, N=10 now becomes N=1. Does this make sense now?
JMP Phillips
JMP Phillips 2015년 8월 20일
still confused sorry, your code just returns a number. Don't you need to specify a range of inputs for the distribution, so that you can find the maximum within the range? In your equation for LL_all, which is the vector input, is it Int?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2015년 8월 17일

댓글:

2015년 8월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by