Constrained regression with constrains on the slopes

I was the following regeression specification
ln Q = ln A + alpha * ln K + beta * ln L
I want to fins alpha and beta such that alpha + beta < 1 and alpha > 0 and beta > 0.
I am trying to use lsqlin but I don't understand how to write the specification.

5 Commenti

Why don't you use directly lsqnonlin and fit
Q = A * K^alpha * L^beta
?
So will it be like:
fun = @(x)A*K^x(1)*L^x(2)
lb = [0 0]
ub = [1 1]
x0 = [0.1 0.1]
x = lsqnonlin(fun,x0,lb,ub)
I did the following:
A = [97.167 97.821 103.409 101.346 101.5943333 100.0346667 99.97166667 100 103.0323333 106.3403333 106.771 107.6006667 113.092 119.3453333 122.0993333];
K = [755193.877 987963.218 1294402.425 1361879.589 1445084.001 1681364.633 1857769.88 1946306.617 2017371.005 2065104.433 1744891.733 1695633.052 1724777.265 1729554.563 1825513.804];
L = [562 619.875 663.2916667 709.1333333 643.4916667 654.8333333 739.3666667 796.6333333 810.7583333 838.3166667 760.2333333 616.8 626.325 677.7166667 677.9416667];
fun = @(x)A*K^x(1)*L^x(2);
lb = [0, 0];
ub = [1, 1];
%x0 = [0 0];
%x = lsqnonlin(fun,x0,lb,ub);
x0 = [0.1, 0.1];
options = optimoptions(@lsqnonlin,'Algorithm','trust-region-reflective');
x = lsqnonlin(fun,x0,ub,lb,options);
And I get the following error:
ProdFuncEval
Exiting due to infeasibility: at least one lower bound exceeds the corresponding upper bound.
But you want to fit Q against A*K^x(1)*L^x(2).
In the above code, you try to make A*K^x(1)*L^x(2) = 0.
Hi, Prerna Mishra, where are the data of Q?

Accedi per commentare.

Risposte (1)

Matt J
Matt J il 26 Lug 2022
Modificato: Matt J il 26 Lug 2022
AA=log(K(:)./L(:));
bb=log(Q(:)./A(:)./L(:));
alpha=min( max(AA\bb,0) ,1 );
beta=1-alpha;

2 Commenti

alpha + beta < 1, not = 1.
Darn it. Well then, why not with lsqlin as originally proposed,
C=[log(K(:)) log(L(:));
d=log(Q(:)./A(:));
x0=lsqlin(C,d,[1,1],1,[],[],[0 0],[1,1]);
alpha=x0(1);
beta=x0(2);
If desired, you can use x0 to initialize a a nonlinear least squares fit to the original non-logged model,
fun = @(x,KL) A(:).'*KL.^x;
lb = [0, 0];
ub = [1, 1];
x=lsqcurvefit(fun,x0(:)',[K(:),L(:)], Q(:), lb,ub);
alpha=x(1);
beta=x(2);

Accedi per commentare.

Richiesto:

il 26 Lug 2022

Commentato:

il 27 Lug 2022

Community Treasure Hunt

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

Start Hunting!

Translated by