Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions archive/docs/fix_longtable.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python
import sys
import os

import sys

BUILDDIR = sys.argv[-1]
read_file_path = os.path.join(BUILDDIR,'latex','statsmodels.tex')
Expand Down
7 changes: 3 additions & 4 deletions archive/tsa/ex_arma.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
'''

import numpy as np

import statsmodels.api as sm
from statsmodels.tsa.arima_process import arma_generate_sample
from statsmodels.tsa.arma_mle import Arma as Arma
from statsmodels.tsa.arima_process import ARIMA as ARIMA_old
from statsmodels.sandbox.tsa.garch import Arma as Armamle_old

from statsmodels.tsa.arima_process import ARIMA as ARIMA_old, arma_generate_sample
from statsmodels.tsa.arma_mle import Arma as Arma

print("\nExample 1")
ar = [1.0, -0.6, 0.1]
Expand Down
6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# serve to show the default.

import contextlib
from packaging.version import parse
import os
from os.path import dirname, join
import sys
from jinja2 import FileSystemLoader, Environment

import yaml
from jinja2 import Environment, FileSystemLoader
from numpydoc.xref import DEFAULT_LINKS
from packaging.version import parse
import yaml

from statsmodels import __version__

Expand Down
2 changes: 1 addition & 1 deletion docs/source/plots/stl_plot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
from pandas.plotting import register_matplotlib_converters

from statsmodels.datasets import co2
Expand Down
8 changes: 5 additions & 3 deletions examples/incomplete/arima.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from statsmodels.datasets.macrodata import load_pandas
from statsmodels.tsa.base.datetools import dates_from_range
from statsmodels.tsa.arima_model import ARIMA
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

import statsmodels.api as sm
from statsmodels.datasets.macrodata import load_pandas
from statsmodels.tsa.arima_model import ARIMA
from statsmodels.tsa.base.datetools import dates_from_range

plt.interactive(False)

# let's examine an ARIMA model of CPI
Expand Down
1 change: 1 addition & 0 deletions examples/incomplete/arma2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import numpy as np
import pandas as pd

import statsmodels.api as sm

# Generate some data from an ARMA process
Expand Down
3 changes: 2 additions & 1 deletion examples/incomplete/dates.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""
Using dates with timeseries models
"""
import statsmodels.api as sm
import pandas as pd

import statsmodels.api as sm

# Getting started
# ---------------

Expand Down
1 change: 1 addition & 0 deletions examples/incomplete/glsar.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import numpy as np
import numpy.testing as npt
from scipy import signal

import statsmodels.api as sm
from statsmodels.regression.linear_model import GLSAR, yule_walker

Expand Down
5 changes: 3 additions & 2 deletions examples/incomplete/ols_table.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Example: statsmodels.OLS
"""

from statsmodels.datasets.longley import load
import numpy as np

import statsmodels.api as sm
from statsmodels.datasets.longley import load
from statsmodels.iolib.table import SimpleTable, default_txt_fmt
import numpy as np

data = load()

Expand Down
1 change: 1 addition & 0 deletions examples/incomplete/ols_tftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import numpy as np
import numpy.testing as npt
from scipy import stats

import statsmodels.api as sm

print('\n\n Example 1: Longley Data, high multicollinearity')
Expand Down
3 changes: 2 additions & 1 deletion examples/incomplete/wls_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
at outliers, compares with RLM and a short bootstrap

"""
import matplotlib.pyplot as plt
import numpy as np

import statsmodels.api as sm
import matplotlib.pyplot as plt

data = sm.datasets.ccard.load()
data.exog = sm.add_constant(data.exog, prepend=False)
Expand Down
1 change: 1 addition & 0 deletions examples/python/autoregressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import pandas as pd
import pandas_datareader as pdr
import seaborn as sns

from statsmodels.tsa.api import acf, graphics, pacf
from statsmodels.tsa.ar_model import AutoReg, ar_select_order

Expand Down
3 changes: 2 additions & 1 deletion examples/python/categorical_interaction_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
# it using the interaction_plot function, which internally re-codes the
# x-factor categories to integers.

import numpy as np
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from statsmodels.graphics.factorplots import interaction_plot

np.random.seed(12345)
Expand Down
1 change: 1 addition & 0 deletions examples/python/chi2_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import numpy as np
import pandas as pd

import statsmodels.api as sm

# ## Linear models
Expand Down
3 changes: 2 additions & 1 deletion examples/python/contrasts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
# # Contrasts Overview

import numpy as np
import pandas as pd

import statsmodels.api as sm

# This document is based heavily on this excellent resource from UCLA
Expand Down Expand Up @@ -41,7 +43,6 @@

# #### Example Data

import pandas as pd

url = "https://stats.idre.ucla.edu/stat/data/hsb2.csv"
hsb2 = pd.read_table(url, delimiter=",")
Expand Down
10 changes: 6 additions & 4 deletions examples/python/copula.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
from scipy import stats
import seaborn as sns

sns.set_style("darkgrid")
sns.mpl.rc("figure", figsize=(8, 8))
Expand All @@ -33,9 +33,11 @@
# In this case, we are using the Gumbel copula and fix its hyperparameter
# `theta=2`. We can visualize it's 2-dimensional PDF.

from statsmodels.distributions.copula.api import (CopulaDistribution,
GumbelCopula,
IndependenceCopula)
from statsmodels.distributions.copula.api import (
CopulaDistribution,
GumbelCopula,
IndependenceCopula,
)

copula = GumbelCopula(theta=2)
_ = copula.plot_pdf() # returns a matplotlib figure
Expand Down
3 changes: 2 additions & 1 deletion examples/python/discrete_choice_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import statsmodels.api as sm
from scipy import stats

import statsmodels.api as sm
from statsmodels.formula.api import logit

print(sm.datasets.fair.SOURCE)
Expand Down
1 change: 1 addition & 0 deletions examples/python/discrete_choice_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# # Discrete Choice Models Overview

import numpy as np

import statsmodels.api as sm

# ## Data
Expand Down
5 changes: 3 additions & 2 deletions examples/python/distributed_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import numpy as np
from scipy.stats.distributions import norm

from statsmodels.base.distributed_estimation import DistributedModel


Expand Down Expand Up @@ -62,8 +63,8 @@ def _endog_gen(endog, partitions):
# Then we run through a slightly more complicated example which uses the
# GLM model class.

from statsmodels.genmod.generalized_linear_model import GLM
from statsmodels.genmod.families import Gaussian
from statsmodels.genmod.generalized_linear_model import GLM

debiased_GLM_mod = DistributedModel(m,
model_class=GLM,
Expand All @@ -89,8 +90,8 @@ def _endog_gen(endog, partitions):
# and naive averaging.

from statsmodels.base.distributed_estimation import (
_est_unregularized_naive,
DistributedResults,
_est_unregularized_naive,
)

naive_OLS_unreg_mod = DistributedModel(
Expand Down
1 change: 0 additions & 1 deletion examples/python/ets.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
# [1] Hyndman, Rob J., and George Athanasopoulos. *Forecasting: principles
# and practice*, 3rd edition, OTexts, 2019. https://www.otexts.org/fpp3/7

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

Expand Down
6 changes: 4 additions & 2 deletions examples/python/exponential_smoothing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
# expedience.

import os

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.api import ExponentialSmoothing, SimpleExpSmoothing, Holt

from statsmodels.tsa.api import ExponentialSmoothing, Holt, SimpleExpSmoothing

data = [
446.6565,
Expand Down
3 changes: 2 additions & 1 deletion examples/python/formulas.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
# ## Loading modules and functions

import numpy as np # noqa:F401 needed in namespace for patsy

import statsmodels.api as sm
from statsmodels.formula.api import ols

# #### Import convention

# You can import explicitly from statsmodels.formula.api

from statsmodels.formula.api import ols

# Alternatively, you can just use the `formula` namespace of the main
# `statsmodels.api`.
Expand Down
1 change: 1 addition & 0 deletions examples/python/gee_nested_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import numpy as np
import pandas as pd

import statsmodels.api as sm

# Set the number of covariates.
Expand Down
5 changes: 3 additions & 2 deletions examples/python/gee_score_test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@
# The level and power of the tests are considered below to assess the
# performance of the tests.

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy.stats.distributions import norm, poisson

import statsmodels.api as sm
import matplotlib.pyplot as plt

# The function defined in the following cell uses a copula approach to
# simulate correlated random values that marginally follow a negative
Expand Down
1 change: 1 addition & 0 deletions examples/python/generic_mle.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import numpy as np
from scipy import stats

import statsmodels.api as sm
from statsmodels.base.model import GenericLikelihoodModel

Expand Down
5 changes: 3 additions & 2 deletions examples/python/glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@

# # Generalized Linear Models

from matplotlib import pyplot as plt
import numpy as np
import statsmodels.api as sm
from scipy import stats
from matplotlib import pyplot as plt

import statsmodels.api as sm

plt.rc("figure", figsize=(16, 8))
plt.rc("font", size=14)
Expand Down
3 changes: 2 additions & 1 deletion examples/python/glm_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@

import numpy as np
import pandas as pd
import statsmodels.formula.api as smf

import statsmodels.api as sm
import statsmodels.formula.api as smf

# ## Weighted GLM: Poisson response data
#
Expand Down
5 changes: 3 additions & 2 deletions examples/python/influence_glm_logit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
# deviance and effects on confidence intervals.

import os.path
import pandas as pd

import matplotlib.pyplot as plt
import pandas as pd

from statsmodels.genmod.generalized_linear_model import GLM
from statsmodels.genmod import families
from statsmodels.genmod.generalized_linear_model import GLM

plt.rc("figure", figsize=(16, 8))
plt.rc("font", size=14)
Expand Down
4 changes: 3 additions & 1 deletion examples/python/interactions_anova.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# Download and format data:

from urllib.request import urlopen

import numpy as np

np.set_printoptions(precision=4, suppress=True)
Expand All @@ -23,8 +24,9 @@

pd.set_option("display.width", 100)
import matplotlib.pyplot as plt

from statsmodels.formula.api import ols
from statsmodels.graphics.api import interaction_plot, abline_plot
from statsmodels.graphics.api import abline_plot, interaction_plot
from statsmodels.stats.anova import anova_lm

try:
Expand Down
3 changes: 2 additions & 1 deletion examples/python/kernel_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
# argument.
# * The various kernel functions available using the `kernel` argument.

import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

import statsmodels.api as sm
import matplotlib.pyplot as plt
from statsmodels.distributions.mixture_rvs import mixture_rvs

# ## A univariate example
Expand Down
Loading
Loading