% IS_LM_AD_AS.m % Questo script MATLAB implementa il modello IS-LM linearizzato e genera un % grafico con 5 pannelli che mostrano i mercati interconnessi, la curva DA e le curve AS. % % TRACCIAMENTO DUPLICE: % - Set 1 (Baseline): Blu % - Set 2 (Modified): Rosso. Questo set può essere modificato per simulare uno shock. % % NUOVO LAYOUT (3x4): % - (1,1) Mercato Moneta (3) | (1,[2-3]) IS-LM (4) | (1,4) Mercato S/I (1) % - (2,1) VUOTO | (2,[2-3]) Croce Keynesiana (2) | (2,4) VUOTO % - (3,1) VUOTO | (3,[2-3]) Domanda Aggregata/Offerta Aggregata (5) | (3,4) VUOTO % % L'allineamento verticale dei pannelli (4), (2) e (5) è assicurato per l'asse X (Reddito/PIL - Y). clear all close all clc set(groot, 'defaultLegendInterpreter', 'latex'); % --- 1. Definizione dei Parametri dei Due Set --- % Definiamo i parametri in una struttura per gestire facilmente i due set. % Livello di produzione naturale (PIL potenziale), fissato per entrambi i set. Y_bar = 2300; %% Parametri Base (Set 1) params_base.a = 150; % Consumo autonomo params_base.b = 0.75; % Propensione Marginale al Consumo (PMC) - Modificato per equilibrio più realistico params_base.c = 400; % Investimento autonomo params_base.d = 2000; % Sensibilità dell'Investimento a r params_base.e = 0.5; % Sensibilità della Domanda di Moneta a Y params_base.f = 3000; % Sensibilità della Domanda di Moneta a r % Variabili esogene Base (Set 1) params_base.G = 200; % Spesa Pubblica params_base.T = 100; % Tasse params_base.M_P = 1000; % Offerta di Saldi Monetari Reali (M/P). Assumiamo M/P all'equilibrio iniziale P_base = 1.0; % Assumiamo P_base = 1 per definire M fisso %% Parametri Modificati (Set 2): Inizialmente Identici a Base. % MODIFICA QUI UN SOLO PARAMETRO PER SIMULARE LO SHOCK. params_modified = params_base; params_modified.a = 150; % mettere 200 per shock positivo a componente autonoma del Consumo params_modified.b = 0.75; % mettere 0.7 per shock negativo a PMC (ad esempio dovuta a deflazione inattesa) params_modified.c = 400; % mettere 300 per shock negativo agli Animal Spirits params_modified.d = 2000; % mettere 2500 per shock negativo a sensibilità dell'investimento al tasso di interesse params_modified.e = 0.5; % mettere 0.4 per shock alla domanda di moneta (come introduzione carte di credito) params_modified.f = 3000; % mettere 2000 per ridurre la sensibilità della domanda di moneta al tasso di interesse params_modified.G = 200; % mettere 300 per politica fiscale espansiva params_modified.T = 100; % mettere 150 per politica fiscale restrittiva params_modified.M_P = 1000; % mettere 1300 per politica monetaria espansiva %% Colleziona i set di parametri e nomi Params = {params_base, params_modified}; Names = {'Baseline (Set 1)', 'Shock (Set 2)'}; Colors = {'b', 'r'}; % Blu per Baseline, Rosso per Shock LineStyles = {'-', '--'}; % Intervallo di PIL per il grafico Y_min = 1500; Y_max = 3500; Y_range = linspace(Y_min, Y_max, 100); % --- 2. Calcolo delle Curve e dell'Equilibrio per Entrambi i Set --- Results = cell(1, 2); for i = 1:2 P = Params{i}; % 2.1. Curva IS A_bar = P.a + P.c + P.G - P.b*P.T; Results{i}.A_bar = A_bar; % Save A_bar for DA Results{i}.r_IS = (1/P.d) * (A_bar - (1-P.b)*Y_range); % 2.2. Curva LM Results{i}.r_LM = (P.e/P.f)*Y_range - (1/P.f)*P.M_P; % 2.3. Equilibrio del Modello (IS = LM) Y_eq = (P.f*A_bar + P.d*P.M_P) / (P.f*(1-P.b) + P.d*P.e); r_eq = (P.e/P.f)*Y_eq - (1/P.f)*P.M_P; Results{i}.Y_eq = Y_eq; Results{i}.r_eq = r_eq; % 2.4. Curve per gli altri Mercati all'Equilibrio Results{i}.I_eq = P.c - P.d*r_eq; Results{i}.S_fixed = Y_eq - (P.a + P.b*(Y_eq - P.T)) - P.G; Results{i}.E_range = A_bar - P.d*r_eq + P.b*Y_range; Results{i}.E_eq = Y_eq; Results{i}.M_P_fixed = P.M_P; Results{i}.L_eq = P.e*Y_eq - P.f*r_eq; % 2.5. Calcolo coefficienti per Domanda Aggregata (DA) % Y = DA_coeff_1 * A_bar + DA_coeff_2 * M/P % Assumiamo M fisso (M_fixed = M/P_base * P_base) M_fixed = P.M_P * P_base; Results{i}.M_fixed = M_fixed; Results{i}.P_eq = P_base; % Livello dei prezzi di equilibrio (assunto) DA_denom = P.f*(1-P.b) + P.d*P.e; Results{i}.DA_coeff_1 = P.f / DA_denom; % Multiplier for A_bar Results{i}.DA_coeff_2 = P.d / DA_denom; % Multiplier for M/P end % --- Definizione Intervalli Globali --- % Intervallo Tasso di Interesse (r) r_all = [Results{1}.r_eq, Results{2}.r_eq, Results{1}.r_IS(1), Results{2}.r_IS(1), Results{1}.r_IS(end), Results{2}.r_IS(end)]; r_min = min(r_all) - 0.01; r_max = max(r_all) + 0.01; r_range = linspace(r_min, r_max, 100); % Intervallo Livello dei Prezzi (P) P_min = 0.5; P_max = 1.5; P_range = linspace(P_min, P_max, 100); % --- 3. Aggiornamento dei Risultati con Intervalli Globali --- for i = 1:2 Res = Results{i}; % Curva I(r) per grafico S/I Results{i}.I_range = P.c - P.d*r_range; % Curva L(r) per grafico Mercato Moneta (Domanda di moneta per Y_eq) Results{i}.L_r_range_full = P.e*Res.Y_eq - P.f*r_range; % Curva Domanda Aggregata (DA): Y = DA_coeff_1 * A_bar + DA_coeff_2 * M/P % M/P = M_fixed / P M_P_range = Res.M_fixed ./ P_range; Results{i}.Y_DA_range = Res.DA_coeff_1 * Res.A_bar + Res.DA_coeff_2 * M_P_range; end % --- 4. Generazione dei 5 Grafici Interconnessi (Layout 3x4) --- fig = figure('Name', 'Modello IS-LM e Domanda Aggregata con Shock'); set(fig, 'WindowState', 'maximized'); % --- Definisci gli Assi --- ax_handles = zeros(1, 5); % 5 assi totali % Pannello (1,1): Mercato della Moneta (Plot 3) ax1 = subplot(3, 4, 1); ax_handles(1) = ax1; title('3) Mercato della Moneta (LM)', 'FontSize', 14); xlabel('Saldi Monetari Reali (L, M/P)', 'FontSize', 12); ylabel('Tasso di Interesse, r', 'FontSize', 12); hold on; for i = 1:2 Res = Results{i}; col = Colors{i}; ls = LineStyles{i}; % Domanda L(r) plot(Res.L_r_range_full, r_range, [col, ls], 'LineWidth', 2, 'DisplayName', ['L(' num2str(Res.Y_eq, '%.0f') ') - ' Names{i}]); % Offerta M/P if i == 1 plot([Res.M_P_fixed, Res.M_P_fixed], [r_min, r_max], 'k:', 'LineWidth', 2, 'DisplayName', 'Offerta M/P'); end % Equilibrio e Linea guida verticale plot(Res.L_eq, Res.r_eq, [col, 'o'], 'MarkerFaceColor', col, 'MarkerSize', 8, 'DisplayName', ['Equil. ' Names{i}]); plot([Res.L_eq, Res.L_eq], [r_min, Res.r_eq], [col, ':']); end grid on; ylim([r_min, r_max]); hold off; % Pannello (1,[2-3]): Curva IS-LM (Plot 4) ax2 = subplot(3, 4, [2 3]); ax_handles(2) = ax2; title('4) Modello IS-LM (Y, r)', 'FontSize', 16, 'FontWeight', 'bold'); xlabel('Reddito, PIL (Y)', 'FontSize', 14); ylabel('Tasso di Interesse, r', 'FontSize', 14); hold on; for i = 1:2 Res = Results{i}; col = Colors{i}; ls = LineStyles{i}; % Curva IS plot(Y_range, Res.r_IS, [col, '-'], 'LineWidth', 3, 'DisplayName', ['IS - ' Names{i}]); % Curva LM plot(Y_range, Res.r_LM, [col, ls], 'LineWidth', 3, 'DisplayName', ['LM - ' Names{i}]); % Equilibrio plot(Res.Y_eq, Res.r_eq, [col, 'o'], 'MarkerFaceColor', col, 'MarkerSize', 10, 'DisplayName', ['Equil. ' Names{i}]); % Linee guida per l'equilibrio plot([Res.Y_eq, Res.Y_eq], [r_min, Res.r_eq], [col, ':']); plot([Y_min, Res.Y_eq], [Res.r_eq, Res.r_eq], [col, ':']); text(Res.Y_eq*1.01, Res.r_eq*1.05, ['Y', num2str(i), ' r', num2str(i)], 'Color', col, 'FontSize', 10); end grid on; legend('Location', 'northeast'); xlim([Y_min, Y_max]); ylim([r_min, r_max]); hold off; % Pannello (1,4): Mercato Risparmio-Investimento (Plot 1) ax3 = subplot(3, 4, 4); ax_handles(3) = ax3; title('1) Mercato Risparmio-Investimento (IS)', 'FontSize', 14); xlabel('Investimento (I) / Risparmio (S)', 'FontSize', 12); ylabel('Tasso di Interesse, r', 'FontSize', 12); hold on; for i = 1:2 Res = Results{i}; col = Colors{i}; ls = LineStyles{i}; % Curva Investimento I(r) plot(Res.I_range, r_range, [col, '-'], 'LineWidth', 2, 'DisplayName', ['Investimento I(r) - ' Names{i}]); % Risparmio S(Y_eq) plot([Res.S_fixed, Res.S_fixed], [r_min, r_max], [col, ls], 'LineWidth', 2, 'DisplayName', ['Risparmio S(Y', num2str(i), ') - ' Names{i}]); % Equilibrio plot(Res.I_eq, Res.r_eq, [col, 'o'], 'MarkerFaceColor', col, 'MarkerSize', 8, 'DisplayName', ['Equil. ' Names{i}]); end grid on; ylim([r_min, r_max]); hold off; % Pannello (2, [2-3]): Croce Keynesiana (Plot 2) ax4 = subplot(3, 4, [6 7]); ax_handles(4) = ax4; title('2) Croce Keynesiana (IS)', 'FontSize', 14); xlabel('Reddito, PIL (Y)', 'FontSize', 12); ylabel('Spesa Programmata (E)', 'FontSize', 12); hold on; for i = 1:2 Res = Results{i}; col = Colors{i}; ls = LineStyles{i}; % Spesa Programmata E(Y, r_eq) plot(Y_range, Res.E_range, [col, ls], 'LineWidth', 2, 'DisplayName', ['E(Y, r', num2str(i), ') - ' Names{i}]); % Equilibrio plot(Res.Y_eq, Res.E_eq, [col, 'o'], 'MarkerFaceColor', col, 'MarkerSize', 8, 'DisplayName', ['Equil. ' Names{i}]); % Linee guida per l'equilibrio plot([Res.Y_eq, Res.Y_eq], [Y_min*0.9, Res.E_eq], [col, ':']); plot([Y_min, Res.Y_eq], [Res.E_eq, Res.E_eq], [col, ':']); end % Spesa Effettiva (E=Y) è sempre la stessa plot([Y_min, Y_max], [Y_min, Y_max], 'k--', 'LineWidth', 1, 'DisplayName', 'Spesa Effettiva (E=Y)'); grid on; legend('Location', 'northwest'); xlim([Y_min, Y_max]); hold off; % Pannello (3, [2-3]): Curva Domanda/Offerta Aggregata (AD/AS) - (Plot 5) ax5 = subplot(3, 4, [10 11]); ax_handles(5) = ax5; title('5) Domanda Aggregata (DA) e Offerta Aggregata (AS)', 'FontSize', 14); xlabel('Reddito, PIL (Y)', 'FontSize', 12); ylabel('Livello dei Prezzi (P)', 'FontSize', 12); hold on; % --- Tracciamento Offerta Aggregata (AS) --- % OALP (Verticale a Y_bar) plot([Y_bar, Y_bar], [P_min, P_max], 'k-', 'LineWidth', 2, 'DisplayName', 'OALP ($\bar{Y}$)'); % OABP (Orizzontale a P_base) plot([Y_min, Y_max], [P_base, P_base], 'k--', 'LineWidth', 2, 'DisplayName', 'OABP ($P_{base}$)'); for i = 1:2 Res = Results{i}; col = Colors{i}; ls = LineStyles{i}; % Curva DA (P on Y-axis, Y on X-axis) plot(Res.Y_DA_range, P_range, [col, ls], 'LineWidth', 3, 'DisplayName', ['DA - ' Names{i}]); % Equilibrio di Breve Periodo (DA=OABP) plot(Res.Y_eq, Res.P_eq, [col, 'o'], 'MarkerFaceColor', col, 'MarkerSize', 8, 'DisplayName', ['Equil. Breve P. ' Names{i}]); % Linee guida per l'equilibrio Y_min_DA = min(Res.Y_DA_range); % Per le linee guida orizzontali plot([Y_min_DA, Res.Y_eq], [Res.P_eq, Res.P_eq], [col, ':']); plot([Res.Y_eq, Res.Y_eq], [P_min, Res.P_eq], [col, ':']); end grid on; legend('Location', 'northeast'); xlim([Y_min, Y_max]); ylim([P_min, P_max]); hold off; % --- 5. Allineamento degli Assi per Connessione Economica --- % 1. Allinea l'asse X (Reddito/PIL - Y) tra IS-LM, Croce Keynesiana e DA/AS (ax2, ax4, ax5) linkaxes([ax_handles(2), ax_handles(4), ax_handles(5)], 'x'); % 2. Allinea l'asse Y (Tasso di Interesse - r) tra Mercato Moneta, IS-LM e S/I (ax1, ax2, ax3) linkaxes([ax_handles(1), ax_handles(2), ax_handles(3)], 'y'); % Titolo generale sgtitle('Analisi Grafica Integrata: IS-LM e Modello AD-AS con Shock', 'FontSize', 18); % Stampa i risultati disp('--- Risultati Equilibrio (P_eq = 1) ---'); for i = 1:2 disp(['Set ' num2str(i) ' (' Names{i} '): Y_eq = ' num2str(Results{i}.Y_eq, '%.2f') ', r_eq = ' num2str(Results{i}.r_eq, '%.4f')]); end