1
- API
2
- ---
3
- The main ~ statsmodels API is split into models:
1
+ API Reference
2
+ =============
3
+ The main statsmodels API is split into models:
4
4
5
- * ``~ statsmodels.api ``: Cross-sectional models and methods. Canonically imported
6
- using ``import ~ statsmodels.api as sm ``.
7
- * ``~ statsmodels.tsa.api ``: Time-series models and methods. Canonically imported
8
- using ``import ~ statsmodels.tsa.api as tsa ``.
5
+ * ``statsmodels.api ``: Cross-sectional models and methods. Canonically imported
6
+ using ``import statsmodels.api as sm ``.
7
+ * ``statsmodels.tsa.api ``: Time-series models and methods. Canonically imported
8
+ using ``import statsmodels.tsa.api as tsa ``.
9
9
10
10
The API focuses on models and the most frequently used statistical test, and tools. See the
11
11
detailed topic pages for a more complete list of available models, statistics, and tools.
12
12
13
13
``statsmodels.api ``
14
- ===================
14
+ -------------------
15
15
16
16
Regression
17
17
~~~~~~~~~~
@@ -107,7 +107,7 @@ Tools
107
107
108
108
109
109
``statsmodels.tsa.api ``
110
- =======================
110
+ -----------------------
111
111
112
112
Statistics and Tests
113
113
~~~~~~~~~~~~~~~~~~~~
@@ -175,9 +175,9 @@ Tools
175
175
~statsmodels.tsa.tsatools.lagmat2ds
176
176
~statsmodels.tsa.seasonal.seasonal_decompose
177
177
~statsmodels.tsa.seasonal.STL
178
- ~statsmodels.tsa.filters.bk_filter
179
- ~statsmodels.tsa.filters.cf_filter
180
- ~statsmodels.tsa.filters.hp_filter
178
+ ~statsmodels.tsa.filters.bk_filter.bkfilter
179
+ ~statsmodels.tsa.filters.cf_filter.cffilter
180
+ ~statsmodels.tsa.filters.hp_filter.hpfilter
181
181
182
182
Markov Switching
183
183
~~~~~~~~~~~~~~~~
@@ -194,3 +194,138 @@ X12/X13 Interface
194
194
195
195
~statsmodels.tsa.x13.x13_arima_analysis
196
196
~statsmodels.tsa.x13.x13_arima_select_order
197
+
198
+ .. _importpaths :
199
+
200
+ Import Paths and Structure
201
+ --------------------------
202
+
203
+ We offer two ways of importing functions and classes from statsmodels:
204
+
205
+ 1. `API import for interactive use `_
206
+
207
+ + Allows tab completion
208
+
209
+ 2. `Direct import for programs `_
210
+
211
+ + Avoids importing unnecessary modules and commands
212
+
213
+ API Import for interactive use
214
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
215
+
216
+ For interactive use the recommended import is:
217
+
218
+ .. code-block :: python
219
+
220
+ import statsmodels.api as sm
221
+
222
+ Importing `statsmodels.api ` will load most of the public parts of statsmodels.
223
+ This makes most functions and classes conveniently available within one or two
224
+ levels, without making the "sm" namespace too crowded.
225
+
226
+ To see what functions and classes available, you can type the following (or use
227
+ the namespace exploration features of IPython, Spyder, IDLE, etc.):
228
+
229
+ .. code-block :: python
230
+
231
+ >> > dir (sm)
232
+ [' GLM' , ' GLS' , ' GLSAR' , ' Logit' , ' MNLogit' , ' OLS' , ' Poisson' , ' Probit' , ' RLM' ,
233
+ ' WLS' , ' __builtins__' , ' __doc__' , ' __file__' , ' __name__' , ' __package__' ,
234
+ ' add_constant' , ' categorical' , ' datasets' , ' distributions' , ' families' ,
235
+ ' graphics' , ' iolib' , ' nonparametric' , ' qqplot' , ' regression' , ' robust' ,
236
+ ' stats' , ' test' , ' tools' , ' tsa' , ' version' ]
237
+
238
+ >> > dir (sm.graphics)
239
+ [' __builtins__' , ' __doc__' , ' __file__' , ' __name__' , ' __package__' ,
240
+ ' abline_plot' , ' beanplot' , ' fboxplot' , ' interaction_plot' , ' qqplot' ,
241
+ ' rainbow' , ' rainbowplot' , ' violinplot' ]
242
+
243
+ >> > dir (sm.tsa)
244
+ [' AR' , ' ARMA' , ' SVAR' , ' VAR' , ' __builtins__' , ' __doc__' ,
245
+ ' __file__' , ' __name__' , ' __package__' , ' acf' , ' acovf' , ' add_lag' ,
246
+ ' add_trend' , ' adfuller' , ' ccf' , ' ccovf' , ' datetools' , ' detrend' ,
247
+ ' filters' , ' grangercausalitytests' , ' interp' , ' lagmat' , ' lagmat2ds' ,
248
+ ' pacf' , ' pacf_ols' , ' pacf_yw' , ' periodogram' , ' q_stat' , ' stattools' ,
249
+ ' tsatools' , ' var' ]
250
+
251
+ Notes
252
+ ^^^^^
253
+
254
+ The `api ` modules may not include all the public functionality of statsmodels. If
255
+ you find something that should be added to the api, please file an issue on
256
+ github or report it to the mailing list.
257
+
258
+ The subpackages of statsmodels include `api.py ` modules that are mainly
259
+ intended to collect the imports needed for those subpackages. The `subpackage/api.py `
260
+ files are imported into statsmodels api, for example ::
261
+
262
+ from .nonparametric import api as nonparametric
263
+
264
+ Users do not need to load the `subpackage/api.py ` modules directly.
265
+
266
+ Direct import for programs
267
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
268
+
269
+ ``statsmodels `` submodules are arranged by topic (e.g. `discrete ` for discrete
270
+ choice models, or `tsa ` for time series analysis). Our directory tree (stripped
271
+ down) looks something like this::
272
+
273
+ statsmodels/
274
+ __init__.py
275
+ api.py
276
+ discrete/
277
+ __init__.py
278
+ discrete_model.py
279
+ tests/
280
+ results/
281
+ tsa/
282
+ __init__.py
283
+ api.py
284
+ tsatools.py
285
+ stattools.py
286
+ arima_model.py
287
+ arima_process.py
288
+ vector_ar/
289
+ __init__.py
290
+ var_model.py
291
+ tests/
292
+ results/
293
+ tests/
294
+ results/
295
+ stats/
296
+ __init__.py
297
+ api.py
298
+ stattools.py
299
+ tests/
300
+ tools/
301
+ __init__.py
302
+ tools.py
303
+ decorators.py
304
+ tests/
305
+
306
+ The submodules that can be import heavy contain an empty `__init__.py `, except
307
+ for some testing code for running tests for the submodules. The intention is to
308
+ change all directories to have an `api.py ` and empty `__init__.py ` in the next
309
+ release.
310
+
311
+ Import examples
312
+ ^^^^^^^^^^^^^^^
313
+
314
+ Functions and classes::
315
+
316
+ from statsmodels.regression.linear_model import OLS, WLS
317
+ from statsmodels.tools.tools import rank, add_constant
318
+
319
+ Modules ::
320
+
321
+ from statsmodels.datasets import macrodata
322
+ import statsmodels.stats import diagnostic
323
+
324
+ Modules with aliases ::
325
+
326
+ import statsmodels.regression.linear_model as lm
327
+ import statsmodels.stats.diagnostic as smsdia
328
+ import statsmodels.stats.outliers_influence as oi
329
+
330
+ We do not have currently a convention for aliases of submodules.
331
+
0 commit comments