GDP GCF Inflation
GDP GCF Inflation
'Inflation': [-3.35, -1.76, 0.04, -1.62, 0.61, -0.21, 2.89, -1.49, 1.57]
}
df = pd.DataFrame(data)
# Correlation matrix
print("Correlation Matrix:")
corr_matrix = df[['GDP_millions', 'GCF_millions', 'Inflation']].corr()
print(corr_matrix)
1
X_gdp = sm.add_constant(df['GCF_millions']) # Adds a constant term to the␣
↪predictor
y_gdp = df['GDP_millions']
# GDP vs GCF
ax1.scatter(df['GCF_millions'], df['GDP_millions'])
ax1.plot(df['GCF_millions'], results_gdp.fittedvalues, color='red')
ax1.set_xlabel('Gross Capital Formation (millions)')
ax1.set_ylabel('GDP (millions)')
ax1.set_title('GDP vs GCF')
# Inflation vs GCF
ax2.scatter(df['GCF_millions'], df['Inflation'])
ax2.plot(df['GCF_millions'], results_inf.fittedvalues, color='red')
ax2.set_xlabel('Gross Capital Formation (millions)')
ax2.set_ylabel('Inflation (%)')
ax2.set_title('Inflation vs GCF')
plt.tight_layout()
plt.show()
Collecting statsmodels
Downloading statsmodels-0.14.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014
_x86_64.whl.metadata (9.2 kB)
Requirement already satisfied: numpy<3,>=1.22.3 in
/usr/local/lib/python3.11/dist-packages (from statsmodels) (2.0.2)
Requirement already satisfied: scipy!=1.9.2,>=1.8 in
/usr/local/lib/python3.11/dist-packages (from statsmodels) (1.14.1)
Requirement already satisfied: pandas!=2.1.0,>=1.4 in
/usr/local/lib/python3.11/dist-packages (from statsmodels) (2.2.2)
Collecting patsy>=0.5.6 (from statsmodels)
2
Downloading patsy-1.0.1-py2.py3-none-any.whl.metadata (3.3 kB)
Requirement already satisfied: packaging>=21.3 in
/usr/local/lib/python3.11/dist-packages (from statsmodels) (24.2)
Requirement already satisfied: python-dateutil>=2.8.2 in
/usr/local/lib/python3.11/dist-packages (from pandas!=2.1.0,>=1.4->statsmodels)
(2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.11/dist-
packages (from pandas!=2.1.0,>=1.4->statsmodels) (2025.2)
Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.11/dist-
packages (from pandas!=2.1.0,>=1.4->statsmodels) (2025.2)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.11/dist-
packages (from python-dateutil>=2.8.2->pandas!=2.1.0,>=1.4->statsmodels)
(1.17.0)
Downloading
statsmodels-0.14.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
(10.8 MB)
���������������������������������������� 10.8/10.8 MB
46.2 MB/s eta 0:00:00
Downloading patsy-1.0.1-py2.py3-none-any.whl (232 kB)
���������������������������������������� 232.9/232.9 kB
18.1 MB/s eta 0:00:00
Installing collected packages: patsy, statsmodels
Successfully installed patsy-1.0.1 statsmodels-0.14.4
Correlation Matrix:
GDP_millions GCF_millions Inflation
GDP_millions 1.000000 0.948508 0.603680
GCF_millions 0.948508 1.000000 0.440572
Inflation 0.603680 0.440572 1.000000
3
Regression 1: GDP ~ GCF
OLS Regression Results
==============================================================================
Dep. Variable: GDP_millions R-squared: 0.900
Model: OLS Adj. R-squared: 0.885
Method: Least Squares F-statistic: 62.77
Date: Wed, 16 Apr 2025 Prob (F-statistic): 9.70e-05
Time: 18:05:22 Log-Likelihood: -7.0432
No. Observations: 9 AIC: 18.09
Df Residuals: 7 BIC: 18.48
Df Model: 1
Covariance Type: nonrobust
================================================================================
coef std err t P>|t| [0.025 0.975]
--------------------------------------------------------------------------------
const 6.5673 0.886 7.410 0.000 4.472 8.663
GCF_millions 1.1456 0.145 7.923 0.000 0.804 1.487
4
==============================================================================
Omnibus: 0.604 Durbin-Watson: 0.951
Prob(Omnibus): 0.740 Jarque-Bera (JB): 0.440
Skew: 0.441 Prob(JB): 0.803
Kurtosis: 2.372 Cond. No. 27.8
==============================================================================
Notes:
[1] Standard Errors assume that the covariance matrix of the errors is correctly
specified.
Notes:
[1] Standard Errors assume that the covariance matrix of the errors is correctly
specified.
/usr/local/lib/python3.11/dist-packages/scipy/stats/_axis_nan_policy.py:418:
UserWarning: `kurtosistest` p-value may be inaccurate with fewer than 20
observations; only n=9 observations were given.
return hypotest_fun_in(*args, **kwds)
/usr/local/lib/python3.11/dist-packages/scipy/stats/_axis_nan_policy.py:418:
UserWarning: `kurtosistest` p-value may be inaccurate with fewer than 20
observations; only n=9 observations were given.
return hypotest_fun_in(*args, **kwds)
5
[ ]: