Borrar filtros
Borrar filtros

Constrained regression with constrains on the slopes

1 visualización (últimos 30 días)
Prerna Mishra
Prerna Mishra el 26 de Jul. de 2022
Comentada: Alex Sha el 27 de Jul. de 2022
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 comentarios
Torsten
Torsten el 26 de Jul. de 2022
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.
Alex Sha
Alex Sha el 27 de Jul. de 2022
Hi, Prerna Mishra, where are the data of Q?

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 26 de Jul. de 2022
Editada: Matt J el 26 de Jul. de 2022
AA=log(K(:)./L(:));
bb=log(Q(:)./A(:)./L(:));
alpha=min( max(AA\bb,0) ,1 );
beta=1-alpha;
  2 comentarios
Torsten
Torsten el 26 de Jul. de 2022
alpha + beta < 1, not = 1.
Matt J
Matt J el 27 de Jul. de 2022
Editada: Matt J el 27 de Jul. de 2022
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);

Iniciar sesión para comentar.

Categorías

Más información sobre Linear Least Squares en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by