I am doing some Maximum Likelihood Estimation with a density that has time-varying parameters. I am using the fmincon function in Matlab, but I do not know how to impose restrictions on a vector of parameters. To be clear, I have a vector of parameters (that do not change over time) and I know how to impose restrictions on them. However I want to make two parameters time-varying and I do not know how to impose restrictions on vectors containing those time-varying parameters. Summing up, I have a vector of a few time-invariant parameters and two vectors of time-varying parameters.

I found a paper that suggests using logistic mapping of the form $ \Theta_{t, restricted} = L + \frac{(U-L)}{1+exp(-\Theta_t)}$ where $\Theta_t = (x_1, x_2)$ and U and L are the upper and lower bounds respectively, for the restricted parameter. $x_1, x_2$ are the time-varying parameters on which I want to impose restrictions.

I would be grateful for any help regarding implementing this logistic mapping into my optimization problem.


1 Answer 1


Here is an MLE I built that uses logistic mapping.

%MLE iterator:
for cxm = 1:cxmax
    for cxth = 1:wx; %thx 
        %Incr. theta within asymptotic min and max.
            thi1 = thA1(cxth,1); mint = thA1(cxth,2); maxt = thA1(cxth,3);
            thix = -log((maxt - mint)/(thi1 - mint) - 1); %Logistic inverse.
            if rand > 0.5; signx = -1; else signx = 1; end
            expn = thix + 0.25 * signx / cxm; 
            thi2 = mint + ((maxt - mint)/(1 + exp(-expn))); %Logistic.
         %Calc. change in log likelihood.
            thA2 = thA1; 
            thA2(cxth,1) = thi2;
                thA2(wx+1:wx*2,1) = min(1,thA2(wx+1:wx*2,1) / sum(thA2(wx+1:wx*2,1))); 
            [llk1] = llkF(rC,thA1,tx,wx);
            [llk2] = llkF(rC,thA2,tx,wx);
        %Calc. update.
            thA3 = thA1;
            expn = thix + 1 * ((llk2 - llk1) / (expn - thix)) / cxm; 
            thA3(cxth,1) = mint + ((maxt - mint)/(1 + exp(-expn))); %Logistic.
                thA3(wx+1:wx*2,1) = min(1,thA3(wx+1:wx*2,1) / sum(thA3(wx+1:wx*2,1))); 
            [llk3] = llkF(rC,thA3,tx,wx);
        %Update thA1 only if thA2 or thA3 is better.
            disp([llk1 llk2 llk3]); %<<<<<<<<<<<<<<<<<<<<<<
            if llk2 > llk1 && llk2 > llk3; thA1 = thA2; llk1 = llk2; end
            if llk3 > llk1 && llk3 > llk2; thA1 = thA3; llk1 = llk3; end
    end%theta loop.
    llkV(cxm) = llk1;
    %disp(['     MLE: ', num2str(cxm),', ll = ',num2str(llk1)])
    %Test for MLE convergence.
        if cxm > 5;
            d5llk = (llkV(cxm) - llkV(cxm - 5)); %Calc. change in llk, lag 5.
            if d5llk < 0.0001; llkV(cxm + 1:cxmax) = llkV(1); 
                break; end; 
end%MLE loop.
llkV = llkV(1:cxm); %Truncate away the zeros.
thA = thA1; %Reset theta array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.