CSV file with full data can be accessed here:
https://nick.fit//blog/linear-regression-analysis/loan_data.csv
import pandas as pd
import numpy as np
import statsmodels.api as sm
loansData = pd.read_csv('loan_data.csv')
pd.plotting.scatter_matrix(loansData,figsize=(15,15),diagonal='kde')
interestRate = loansData['int.rate']
installment = loansData['installment']
logAnnualInc = loansData['log.annual.inc']
dti = loansData['dti']
fico = loansData['fico']
daysWithCrLine = loansData['days.with.cr.line']
revolUtil = loansData['revol.util']
y = np.matrix(interestRate).transpose()
x1 = np.matrix(installment).transpose()
x2 = np.matrix(logAnnualInc).transpose()
x3 = np.matrix(dti).transpose()
x4 = np.matrix(fico).transpose()
x5 = np.matrix(daysWithCrLine).transpose()
x6 = np.matrix(revolUtil).transpose()
x = np.column_stack([x1,x2,x3,x4,x5,x6])
# create a linear model
X = sm.add_constant(x)
model = sm.OLS(y,X)
f = model.fit()
print ("pvalues = %s, rsquared = %s" % (f.pvalues, f.rsquared))
print ("Intercept = %s, Coefficients = %s" % (f.params[2], f.params[0:2]))
x = np.column_stack([x1,x4])