Generalized beta distribution error

Hi all,

I think there is an error in the generalized beta distribution. I am talking specifically about the priordens.m file in dynare.

In that file, the formula for calculating shape and scale parameters are correct only if the range on the beta distribution is (0,1).

However, if the range is not (0,1) and something else, I doubt if that is the correct way to calculate the shape and scale parameters.

if pshape(i) == 1; % (generalized) BETA Prior
mu = (p1(i)-p3(i))/(p4(i)-p3(i));
stdd = p2(i)/(p4(i)-p3(i));
a = (1-mu)mu^2/stdd^2 - mu;
b = a
(1/mu - 1);
lnprior = lnprior + lpdfgbeta(para(i),a,b,p3(i),p4(i)) ;

Here mu and stdd are calculated for range (p3,p4). However, the formula for calculating a,b assumes that p3,p4 = 0,1. Therefore if p3,p4 is not equal to 0,1 that would give us incorrect results. Could someone please confirm this. I do not know what the correct formula should be for calculating a,b when p3,p4 is not equal to 0,1. I think that is something very complicated.