Skip to content

Instantly share code, notes, and snippets.

"""
Self-Exciting Threshold Autoregression
References
----------
Hansen, Bruce. 1999.
"Testing for Linearity."
Journal of Economic Surveys 13 (5): 551-576.
"""
@ChadFulton
ChadFulton / linear_model.py
Created August 5, 2013 19:33
Setar multiple inheritance
diff --git a/statsmodels/regression/linear_model.py b/statsmodels/regression/linear_model.py
index e4be23e..d7cf538 100644
--- a/statsmodels/regression/linear_model.py
+++ b/statsmodels/regression/linear_model.py
@@ -90,7 +90,7 @@ class RegressionModel(base.LikelihoodModel):
self.df_resid = self.nobs - self.rank
self.df_model = float(rank(self.exog) - self.k_constant)
- def fit(self, method="pinv", **kwargs):
+ def _fit(self, method="pinv", **kwargs):
@ChadFulton
ChadFulton / gist:6202381
Created August 10, 2013 22:04
SETAR Notebook Example: Sunposts - Rendered
{
"metadata": {
"name": "SETAR Example - Sunspots"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@ChadFulton
ChadFulton / structural_change.py
Created September 3, 2013 16:35
SupF test for structural breaks, allowing multiple structural breaks, from Bai and Perron.
"""
Structural Change
References
----------
Bai, Jushan, and Pierre Perron. 1998.
"Estimating and Testing Linear Models with Multiple Structural Changes."
Econometrica 66 (1) (January 1): 47-78.
@ChadFulton
ChadFulton / star_model.py
Created September 7, 2013 18:54
LSTAR1 model
"""
Smooth Transition Autoregression
References
----------
Dijk, Dick van, Timo Terasvirta, and Philip Hans Franses. 2002.
"Smooth Transition Autoregressive Models - a Survey of Recent Developments."
Econometric Reviews 21 (1): 1-47.
@ChadFulton
ChadFulton / hamilton_filter.pyx
Created September 15, 2013 12:08
Markov Switching Models - first pass at the Filter / Maximum Likelihood Estimation.
import numpy as np
cimport numpy as np
cimport cython
DTYPE = np.float64
ctypedef np.float64_t dtype_t
@cython.boundscheck(False)
@cython.wraparound(False)
def hamilton_filter(int nobs,
int nstates,
@ChadFulton
ChadFulton / gist:7535278
Created November 18, 2013 21:06
Statsmodels ARIMA Example
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
# Typical imports
from cpython cimport PyCObject_AsVoidPtr
import numpy as np
cimport numpy as np
cimport cython
# BLAS / LAPACK functions
from blas_lapack cimport *
from scipy.linalg import blas, lapack
@ChadFulton
ChadFulton / inversion.ipynb
Last active August 29, 2015 14:03
Python vs Cython - Timings
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ChadFulton
ChadFulton / _dStatespace.html
Last active August 29, 2015 14:03
Literate Programming Output: _statespace
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>_statespace.pyx</title>
<style>
/*--------------------- Layout and Typography ----------------------------*/
body {
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
font-size: 16px;