On Thu, 14 Sep 2017, Sven Schreiber wrote:
Am 13.09.2017 um 23:38 schrieb Allin Cottrell:
> On Wed, 13 Sep 2017, Sven Schreiber wrote:
>
>> Am 13.09.2017 um 23:01 schrieb Allin Cottrell:
>>> My impression is that "sane" values of theta have theta_1 around
1.0
>>> and theta_2 > theta_1 -- and that such vectors will respect the "zero
>>> last lag" condition.
Hm, yes and no. I have manually coded the equations 2.10/2.12 in
Ghysels' user guide (version 8), that is the zero-last-lag beta case,
and _sometimes_ (but not always) get different results from gretl's
mweights() function with type==2. For example:
<hansl>
function matrix weightcrosscheck(int N, scalar th1, scalar th2)
matrix w = -1 * ones(N,1)
denom = 0
loop i=1..N --quiet
x = (i-1) / (N-1)
w[i] = x^(th1 - 1) * (1-x)^(th2 - 1)
denom += w[i]
endloop
w = w ./ denom
return w
end function
N = 9
## mismatch:
th1 = 1.01
th2 = 1.02
eval weightcrosscheck(N, th1, th2) # last weight: 0.0000
eval mweights(N, {th1, th2}, 2) # last weight: 0.0608
## a matching case (but not th1 < th2):
th1 = 2
th2 = 1
eval weightcrosscheck(N, th1, th2) # last weight: 0.22
eval mweights(N, {th1, th2}, 2) # last weight: 0.22
</hansl>
Gretl's mweights() results agree with those from Ghysels' Matlab code,
which differ from your weightcrosscheck. Here's the function he uses:
<matlab>
function [be_values]=b_weights(ind,k1,k2)
%Beta weights function.
if length(ind)>1
u=(ind(1)-ind)/(ind(1)-ind(end));
u(1)=u(1)+eps;
u(end)=u(end)-eps;
end
if isscalar(ind)
u=linspace(eps,1-eps,ind)';
end
be_values=u.^(k1-1).*(1-u).^(k2-1);
be_values=be_values/sum(be_values);
end
</matlab>
Octave gives the following for b_weights(9, 1.01, 1.02):
0.087114
0.122020
0.122491
0.122541
0.122347
0.121916
0.121152
0.119669
0.060751
Allin