Gaussian_GLM
from spglm.glm import GLM
import libpysal.api as ps
import numpy as np
#Load sample dataset - columbus dataset
db = ps.open(ps.get_path('columbus.dbf'),'r')
#Set dependent variable
y = np.array(db.by_col("HOVAL"))
y = np.reshape(y, (49,1))
#Set indepdent varibLES
X = []
X.append(db.by_col("INC"))
X.append(db.by_col("CRIME"))
X = np.array(X).T
#Estimate Gaussian GLM
#First instantiate a GLM model object
model = GLM(y, X) #Gaussian is the default family parameter so it doesn't need to be set
#Then use the fit method to estimate coefficients and compute diagnostics
results = model.fit()
#Estimated prameters, intercept is always the first column on the left
print(results.params)
#Parameter standard errors
print(results.bse)
#Parameter t-values
print(results.tvalues)
#Model AIC
print(results.aic)