On Sun, 6 Oct 2019, Alecos Papadopoulos wrote:
Related to my earlier request, the following works (perhaps
clumsily), so
maybe it will be useful to somebody else also.
A marginally more efficient version:
<hansl>
set verbose off
function scalar udensity (matrix param, const scalar sv, const scalar thu, scalar resk)
scalar x = param[1]
scalar a = x/sv^2
scalar b = x/thu
densu = -0.5*x*a - resk*b - b + log(1-exp(-b)) # this is the conditional density of
"param"
return densu
end function
nulldata 50
series res = randgen(N,0,1) #the conditioning variable
scalar sv = 0.3 #remains fixed
scalar thu = 0.5 #remains fixed
series mode = NA
loop i=1..$nobs --quiet
matrix b = {0, 0, 10}
densval = GSSmax(b, udensity(b, sv, thu, res[i]))
series mode[i] = b[1]
endloop
gnuplot mode res --output=display --fit=none
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------