Line 32 is lambda_sq=(pir.*wr_sq.*lr_sq + pin.*wn_sq.*ln_sq) - g(pin.*wn_sq.*ln_sq.*(taux+alpha./alpha.*(1+taux)) + (pir.*wr_sq.*lr_sq./(1+taux))) ./ (pir.*(wr_sq.*lr_sq).^(1-gamma_sq) + pin.*(wn_sq.*ln_sq).^(1-gamma_sq));%% Goverment budget constraint with taux
Why do I receive the error message "Array indices must be positive integers or logical values. Error in Master (line 32)"
1 view (last 30 days)
Show older comments
This is my master code:
clear all;
clc;
%% Preamble
Parameters;
taux= 0.5; % robot tax
pir = pi_pred(2,:); %% fraction of routine workers
pin = pi_pred(1,:); %% fraction of non-routine
u=@(c) log(c); %Utility of consumption
up=@(c) 1./c; %Mg Utility of c
psi = @(l) zeta*l.^(1+nu)/(1+nu); %Labor disutility
psip = @(l) zeta*l.^nu; %Mg Utility Labor
util=@(c,l) u(c)-psi(l);
welf = @(un,ur,G,pn,pr) omegan*pn.*un+omegar*pr.*ur+chi*u(G);
%% Solve each model
g = gc./(1+gc);
fprintf('Solving Status Quo \n')
gamma_sq=gamma;
for t = 1 : T+1
lr_sq(t)=fzero(@(l) psip(l)*l-(1-gamma_sq),0.3);
ln_sq(t)=fzero(@(l) psip(l)*l-(1-gamma_sq),0.3);
end
taux_sq = 0.1*ones(1,T+1);
m_sq=1-(((1+taux)*phi)/(A*(1-alpha))).^(1/alpha).*(pir.*lr_sq./(pin.*ln_sq));
% wr_sq=(0.1+1)*phi;
wr_sq=(1+taux)*phi; %% routine wages with taux
wn_sq=A^(1/alpha)*alpha*(1-alpha)^((1-alpha)/alpha)./((1+taux)*phi).^((1-alpha)/alpha); %% non-routine wages with taux
G_sq=g.*(pir.*wr_sq.*lr_sq+pin.*wn_sq.*ln_sq);
lambda_sq=(pir.*wr_sq.*lr_sq + pin.*wn_sq.*ln_sq) - g(pin.*wn_sq.*ln_sq.*(taux+alpha./alpha.*(1+taux)) + (pir.*wr_sq.*lr_sq./(1+taux))) ./ (pir.*(wr_sq.*lr_sq).^(1-gamma_sq) + pin.*(wn_sq.*ln_sq).^(1-gamma_sq));%% Goverment budget constraint with taux
% taux_sq=zeros(1,T+1);
cr_sq=lambda_sq.*(wr_sq.*lr_sq).^(1-gamma_sq);
cn_sq=lambda_sq.*(wn_sq.*ln_sq).^(1-gamma_sq);
Ur_sq=util(cr_sq,lr_sq)+chi*u(G_sq);
Un_sq=util(cn_sq,ln_sq)+chi*u(G_sq);
W_sq=welf(util(cn_sq,ln_sq),util(cr_sq,lr_sq),G_sq,pin,pir);
%% Draw plots
DrawPlots;
This is my parameter code:
%% Parameters
T = 500; % Number of periods to be solved each period is 1 year
load('../Calibration/MatFiles/Calibration.mat','par','target');
%% Data for occupations
load('../Data/Occupations Data/occ_data.mat','pi','year')
index = find(year == 1987);
pi_fix = pi(1,index:end);
% The first hypothesis assumes shares will stay constant forever
pi_fix(end:T+1) = pi(1,end);
pi_fix(2,:) = 1 - pi_fix(1,:);
% Can also do shares evolving exogenously over time
y = log(1-pi(1,:));
x = [ones(1,size(pi,2)); 0:1:size(pi,2)-1];
bet = (x*x')^(-1)*(x*y');
pi_pred(1,1:T+1) = 1 - exp(bet(1)+bet(2)*(0:1:T));
% pi_pred(1,1:size(pi,2)-index+1) = pi(1,:);
pi_pred(2,:) = 1 - pi_pred(1,:);
clear year pi y x bet;
gamma = par.gamma; % 0.1845
gamma = 0.1845;
%% Preferences
nu = par.nu;
zeta = par.zeta;
% zeta = 15
chi = par.chi;
%% Production
A = par.A;
phi = par.phitilde*exp(-par.gphi/10*(0:1:T));
alpha = par.alpha;
%% Get data for government
gc = target.gc;
%% Planner Pareto weights
omegar = 1;
omegan = 1;
%Time path for phi
time=0:1:T;
time_label=1987:1:(1986+T+1);
Ngrid=T+1;
clear par;
Accepted Answer
Star Strider
on 10 Mar 2023
I am guessinmg that it could be:
lambda_sq=(pir.*wr_sq.*lr_sq + pin.*wn_sq.*ln_sq) - g(pin.*wn_sq.*ln_sq.*(taux+alpha./alpha.*(1+taux)) + (pir.*wr_sq.*lr_sq./(1+taux))) ./ (pir.*(wr_sq.*lr_sq).^(1-gamma_sq) + pin.*(wn_sq.*ln_sq).^(1-gamma_sq));%% Goverment budget constraint with taux
↑ ← HERE
and there should be an element-wise multiplication operator: ... g.*( ... there.
.
2 Comments
More Answers (0)
See Also
Categories
Find more on Multibody Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!