Skip to content

Commit

Permalink
Merge tag 'v0.4.0rc2' into debian
Browse files Browse the repository at this point in the history
Version 0.4.0 Release Candidate 2

* tag 'v0.4.0rc2':
  RLS: Set version number to 0.4.0rc2
  ENH: Do not warn on explicit prepend. Closes statsmodels#217.
  REF/BUG: fix nobs in old example
  REF: sandbox example make rpy optional in garch example
  BUG: fix statsmodels/examples for refactoring bugs, change the run_all.py (glob)
  TST: reduce precision test for breaks_hansen (reported by Yaroslav for Debian)
  BUG: Add return statement to predict. Needs tests! Closes statsmodels#220.
  ENH add IV2SLS to sandbox sysreg example
  BUG: fix import path in sandbox example
  Docs: add license for qsturng-py and license notice for ordereddict
  DOC: Update stale examples. Closes statsmodels#219.
  DOC: Fix example
  EX: Remove scikits.ts and larry from example
  EX: Add seed to example and use stationary coefs
  DOC: Fix lag 0 doc. Closes statsmodels#216.
  • Loading branch information
yarikoptic committed Apr 11, 2012
2 parents 2e9c990 + 710f080 commit 898303a
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 28 deletions.
37 changes: 35 additions & 2 deletions COPYRIGHTS.txt
Expand Up @@ -16,11 +16,11 @@ scipy
pandas
matplotlib
scikit-learn

qsturng-py http://code.google.com/p/qsturng-py/


numpy (statsmodels.compatnp contains copy of entire model)
------------------------------------------------------------------
----------------------------------------------------------
Copyright (c) 2005-2009, NumPy Developers.
All rights reserved.

Expand Down Expand Up @@ -125,6 +125,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


matplotlib (copied from license.py)
-----------------------------------


LICENSE AGREEMENT FOR MATPLOTLIB %(version)s
Expand Down Expand Up @@ -214,3 +215,35 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
---------------------------------------------------------------------------

qsturng-py (code included in statsmodels.stats.libqsturng)
--------------------------------------------------------------
Copyright (c) 2011, Roger Lew [see LICENSE.txt]
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the organizations affiliated with the
contributors or the names of its contributors themselves may be
used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -69,7 +69,7 @@ def check_dependency_versions(min_versions):
MIN = 4
REV = 0
ISRELEASED = True
VERSION = '%d.%d.%drc1' % (MAJ,MIN,REV)
VERSION = '%d.%d.%drc2' % (MAJ,MIN,REV)

classifiers = [ 'Development Status :: 4 - Beta',
'Environment :: Console',
Expand Down
4 changes: 4 additions & 0 deletions statsmodels/compatnp/ordereddict.py
@@ -1,6 +1,10 @@
# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy.
# Passes Python2.7's test suite and incorporates all the latest updates.

#Author: Raymond Hettinger
#License: MIT License
#http://code.activestate.com/recipes/576693/ revision 9, downloaded 2012-03-28

try:
from thread import get_ident as _get_ident
except ImportError:
Expand Down
2 changes: 1 addition & 1 deletion statsmodels/examples/es_misc_poisson2.py
Expand Up @@ -23,7 +23,7 @@ class Dummy(object):
data_endog = np.random.poisson(np.exp(xbeta))

#estimate discretemod.Poisson as benchmark
from statsmodels.discretemod import Poisson
from statsmodels.discrete.discrete_model import Poisson
res_discrete = Poisson(data_endog, data_exog).fit()

mod_glm = sm.GLM(data_endog, data_exog, family=sm.families.Poisson())
Expand Down
2 changes: 1 addition & 1 deletion statsmodels/examples/ex_generic_mle.py
Expand Up @@ -2,7 +2,7 @@
import numpy as np
from scipy import stats
import statsmodels.api as sm
from statsmodels.model import GenericLikelihoodModel
from statsmodels.base.model import GenericLikelihoodModel


data = sm.datasets.spector.load()
Expand Down
2 changes: 1 addition & 1 deletion statsmodels/examples/ex_generic_mle_t.py
Expand Up @@ -10,7 +10,7 @@

from scipy import stats, special
import statsmodels.api as sm
from statsmodels.model import GenericLikelihoodModel
from statsmodels.base.model import GenericLikelihoodModel

#redefine some shortcuts
np_log = np.log
Expand Down
5 changes: 3 additions & 2 deletions statsmodels/examples/ex_generic_mle_tdist.py
Expand Up @@ -10,7 +10,7 @@

from scipy import stats, special, optimize
import statsmodels.api as sm
from statsmodels.model import GenericLikelihoodModel
from statsmodels.base.model import GenericLikelihoodModel

#redefine some shortcuts
np_log = np.log
Expand Down Expand Up @@ -159,7 +159,7 @@ def nloglikeobs(self, params):

#import for kstest based estimation
#should be replace
import statsmodels.sandbox.stats.distributions_patch
import statsmodels.sandbox.distributions.sppatch

class MyPareto(GenericLikelihoodModel):
'''Maximum Likelihood Estimation pareto distribution
Expand Down Expand Up @@ -223,6 +223,7 @@ def fit_ks1_trim(self):
originally published on stackoverflow
'''
self.nobs = self.endog.shape[0]
rvs = np.sort(self.endog)
rvsmin = rvs.min()

Expand Down
4 changes: 2 additions & 2 deletions statsmodels/examples/ex_pandas.py
Expand Up @@ -28,9 +28,9 @@
print results.cov_params()

infl = results.get_influence()
print infl.summary_obs()
print infl.summary_table()

raise
#raise

#Example RLM
huber_t = sm.RLM(Y, X, M=sm.robust.norms.HuberT())
Expand Down
22 changes: 21 additions & 1 deletion statsmodels/examples/run_all.py
Expand Up @@ -7,8 +7,9 @@
uncomment plt.show() to show all plot windows
'''
import matplotlib.pyplot as plt #matplotlib is required for many examples

stop_on_error = False #True
stop_on_error = True


filelist = ['example_glsar.py', 'example_wls.py', 'example_gls.py',
Expand All @@ -18,6 +19,20 @@
'example_ols_table.py',
'tut_ols.py', 'tut_ols_rlm.py', 'tut_ols_wls.py']

use_glob = True
if use_glob:
import glob
filelist = glob.glob('*.py')

print zip(range(len(filelist)), filelist)

for fname in ['run_all.py', 'example_rpy.py']:
filelist.remove(fname)

#filelist = filelist[15:]



#temporarily disable show
plt_show = plt.show
def noop(*args):
Expand All @@ -28,6 +43,7 @@ def noop(*args):
This is done mainly to check that they are up to date.
(y/n) >>> """)
if 'y' in cont.lower():
has_errors = []
for run_all_f in filelist:
try:
print "\n\nExecuting example file", run_all_f
Expand All @@ -38,9 +54,13 @@ def noop(*args):
print "**********************" + "*"*len(run_all_f)
print "ERROR in example file", run_all_f
print "**********************" + "*"*len(run_all_f)
has_errors.append(run_all_f)
if stop_on_error:
raise

print '\nModules that raised exception:'
print has_errors

#reenable show after closing windows
plt.close('all')
plt.show = plt_show
Expand Down
4 changes: 2 additions & 2 deletions statsmodels/regression/linear_model.py
Expand Up @@ -116,7 +116,8 @@ class GLS(base.LikelihoodModel):
data.
>>> gls_model = sm.GLS(data.endog, data.exog, sigma=sigma)
>>> gls_results = gls_model.results
>>> gls_results = gls_model.fit()
>>> print gls_results.summary()
"""

Expand Down Expand Up @@ -482,7 +483,6 @@ class OLS(WLS):
>>>
>>> model = sm.OLS(Y,X)
>>> results = model.fit()
>>> # or results = model.results
>>> results.params
array([ 0.25 , 2.14285714])
>>> results.tvales
Expand Down
4 changes: 2 additions & 2 deletions statsmodels/sandbox/examples/ex_cusum.py
Expand Up @@ -11,8 +11,8 @@
from numpy.testing import assert_almost_equal
import statsmodels.api as sm
from statsmodels.sandbox.regression.onewaygls import OneWayLS
from statsmodels.sandbox.stats.diagnostic import (recursive_olsresiduals,
recursive_olsresiduals2)
from statsmodels.stats.diagnostic import recursive_olsresiduals
from statsmodels.sandbox.stats.diagnostic import _recursive_olsresiduals2 as recursive_olsresiduals2

#examples from ex_onewaygls.py
#choose example
Expand Down
15 changes: 8 additions & 7 deletions statsmodels/sandbox/examples/example_garch.py
Expand Up @@ -29,13 +29,14 @@
print 'ggres.params', ggres.params
garchplot(ggmod.errorsest, ggmod.h, title='Garch estimated')


from rpy import r
r.library('fGarch')
f = r.formula('~garch(1, 1)')
fit = r.garchFit(f, data = ret - ret.mean(), include_mean=False)
f = r.formula('~arma(1,1) + ~garch(1, 1)')
fit = r.garchFit(f, data = ret)
use_rpy = False
if use_rpy:
from rpy import r
r.library('fGarch')
f = r.formula('~garch(1, 1)')
fit = r.garchFit(f, data = ret - ret.mean(), include_mean=False)
f = r.formula('~arma(1,1) + ~garch(1, 1)')
fit = r.garchFit(f, data = ret)


ggmod0 = Garch0(ret - ret.mean())#hgjr4[:nobs])#-hgjr4.mean()) #errgjr4)
Expand Down
10 changes: 10 additions & 0 deletions statsmodels/sandbox/examples/example_sysreg.py
Expand Up @@ -131,6 +131,16 @@
print correct_params
print "Compare to output of R script statsmodels/sandbox/tests/macrodata.s"

print '\nUsing IV2SLS'
from statsmodels.sandbox.regression.gmm import IV2SLS
miv = IV2SLS(macro_sys[0], macro_sys[1], instruments)
resiv = miv.fit()
print "equation 1"
print resiv.params
miv2 = IV2SLS(macro_sys[2], macro_sys[3], instruments)
resiv2 = miv2.fit()
print "equation 2"
print resiv2.params

### Below is the same example using Greene's data ###

Expand Down
2 changes: 1 addition & 1 deletion statsmodels/stats/tests/test_diagnostic.py
Expand Up @@ -444,7 +444,7 @@ def test_breaks_hansen(self):

bh = smsdia.breaks_hansen(self.res)
assert_almost_equal(bh[0], breaks_nyblom_hansen['statistic'],
decimal=14)
decimal=13)
#TODO: breaks_hansen doesn't return pvalues


Expand Down
16 changes: 13 additions & 3 deletions statsmodels/tools/tools.py
Expand Up @@ -286,9 +286,19 @@ def add_constant(data, prepend=False):
code.
'''
if not prepend:
import warnings
warnings.warn("The default of `prepend` will be changed to True in the "
"next release, use explicit prepend", FutureWarning)
import inspect
frame = inspect.currentframe().f_back
info = inspect.getframeinfo(frame)
try:
to_warn = '\n'.join(info.code_context)
except: # python 2.5 compatibility
to_warn = '\n'.join(info[3])
if to_warn:
import warnings
warnings.warn("The default of `prepend` will be changed to True "
"in 0.5.0, use explicit prepend",
FutureWarning)

if _is_using_pandas(data, None):
# work on a copy
return _pandas_add_constant(data.copy(), prepend)
Expand Down
2 changes: 1 addition & 1 deletion statsmodels/tsa/arima_model.py
Expand Up @@ -841,7 +841,7 @@ def predict(self, start=None, end=None, exog=None):
If the model is an ARMAX and out-of-sample forecasting is
requestion, exog must be given.
"""
self.model.predict(self.params, start, end, exog)
return self.model.predict(self.params, start, end, exog)

def forecast(self, steps=1, exog=None, alpha=.05):
"""
Expand Down
2 changes: 1 addition & 1 deletion statsmodels/tsa/filters/bk_filter.py
Expand Up @@ -49,7 +49,7 @@ def bkfilter(X, low=6, high=32, K=12):
>>> import statsmodels.api as sm
>>> dta = sm.datasets.macrodata.load()
>>> X = dta.data['realinv']
>>> Y = sm.tsa.filters.baxter_king(X, 6, 24, 12)
>>> Y = sm.tsa.filters.bkfilter(X, 6, 24, 12)
"""
#TODO: change the docstring to ..math::?
#TODO: allow windowing functions to correct for Gibb's Phenomenon?
Expand Down

0 comments on commit 898303a

Please sign in to comment.