# How To Approximate Data With Model

2 views (last 30 days)
econogist on 6 May 2022
Answered: Mathieu NOE on 9 May 2022
I have a model that spits out TFPmodel as shown in the code below. I want to show how the vector called TFPmodel can approximate actual TFP growth (realgA in code below) from 1950 to 2100. The problem is TFPmodel is a size of 1X31. Is there any way I can get this to approximate the whole period so it looks like the other ("Other.png") attached image?
Year=realdata(:,1);
realgA=realdata(:,2);
TFPmodel=[0 0.01 0.012 0.015 0.02 0.025 0.025 0.025 0.025 0.025 0.026 0.025 0.026 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025];
plot(Year, realgA, 'r--', 'LineWidth', 1.5)
set(gca,'FontName','Times','FontSize',11);
ylabel('TFP growth (g_A)','FontSize',11)
ylim([-0.01 0.05])
yticks([-0.01 0 0.01 0.02 0.03 0.04 0.05])
xlim([1950 2100])
hold on
grid on
box on

Mathieu NOE on 9 May 2022
hello
maybe this ?
clc
clearvars
Year=realdata(:,1);
realgA=realdata(:,2);
TFPmodel=[0 0.01 0.012 0.015 0.02 0.025 0.025 0.025 0.025 0.025 0.026 0.025 0.026 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025 0.025];
TFPmodel2 = interp1((0:numel(TFPmodel)-1)./numel(TFPmodel),TFPmodel,(0:numel(Year)-1)./numel(Year));
plot(Year, realgA, 'r--', 'LineWidth', 1.5)
hold on
plot(Year,TFPmodel2)
grid on
set(gca,'FontName','Times','FontSize',11);
ylabel('TFP growth (g_A)','FontSize',11)
ylim([-0.01 0.05])
yticks([-0.01 0 0.01 0.02 0.03 0.04 0.05])
xlim([1950 2100])
box on