spreg.f_stat

spreg.f_stat(reg)[source]

Calculates the f-statistic and associated p-value of the regression. [Gre03]. (For two stage least squares see f_stat_tsls)

Parameters
regregression object

output instance from a regression model

Returns
fs_resulttuple

includes value of F statistic and associated p-value

Examples

>>> import numpy as np
>>> import libpysal
>>> from libpysal import examples
>>> import spreg
>>> from spreg import OLS

Read the DBF associated with the Columbus data.

>>> db = libpysal.io.open(libpysal.examples.get_path("columbus.dbf"),"r")

Create the dependent variable vector.

>>> y = np.array(db.by_col("CRIME"))
>>> y = np.reshape(y, (49,1))

Create the matrix of independent variables.

>>> X = []
>>> X.append(db.by_col("INC"))
>>> X.append(db.by_col("HOVAL"))
>>> X = np.array(X).T

Run an OLS regression.

>>> reg = OLS(y,X)

Calculate the F-statistic for the regression.

>>> testresult = spreg.f_stat(reg)

Print the results tuple, including the statistic and its significance.

>>> print("%12.12f"%testresult[0],"%12.12f"%testresult[1])
28.385629224695 0.000000009341