
function [ns, y, a,  beta, alpha, theta, LT, KT ] = Calibrar(data)

nf=size(data,1);

ns=nf-2;

y=zeros(1,ns);
l=size(y);
k=size(y);
alpha=size(y);
beta=size(y);

c=zeros(1,ns+1);
theta=size(c);

for i=1:ns
    y(i)=sum(data(:,i));
end

LT=sum(data(ns+1,:));
KT=sum(data(ns+2,:));

Income=LT+KT;

c=data(1:ns,ns+1)';
c(ns+1)=sum(data(1:ns,ns+2));

for i=1:ns+1
    theta(i)=c(i)./Income;
end

for i=1:ns
    l(i)=data(ns+1,i);
    k(i)=data(ns+2,i);
    y(i)=sum(data(i,:));

    alpha(i)=(k(i)/l(i))/(1+(k(i)/l(i)));
    beta(i)=y(i)./(k(i)^alpha(i)*l(i)^(1-alpha(i)));
end

a=data(1:ns,1:ns)./y;
a(:,ns+1)=data(1:ns,ns+2)./c(ns+1);

