-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpitfalls.html
963 lines (523 loc) · 38.3 KB
/
pitfalls.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" href="_static/favicon.ico">
<title>Pitfalls - statsmodels 0.15.0 (+617)</title>
<link rel="icon" type="image/png" sizes="32x32" href="_static/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="_static/icons/favicon-16x16.png">
<link rel="manifest" href="_static/icons/site.webmanifest">
<link rel="mask-icon" href="_static/icons/safari-pinned-tab.svg" color="#919191">
<meta name="msapplication-TileColor" content="#2b5797">
<meta name="msapplication-config" content="_static/icons/browserconfig.xml">
<link rel="stylesheet" href="_static/stylesheets/examples.css">
<link rel="stylesheet" href="_static/stylesheets/deprecation.css">
<meta name="theme-color" content="#4051b5">
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
<link rel="stylesheet" type="text/css" href="_static/sphinx_immaterial_theme.02cb18745d09eea51.min.css?v=ff456132" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css?v=fd3f3429" />
<link rel="stylesheet" type="text/css" href="_static/plot_directive.css" />
<script>__md_scope=new URL(".",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
</head>
<body dir="ltr" data-md-color-scheme="" data-md-color-primary="indigo" data-md-color-accent="blue">
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">
<a href="#repeated-calls-to-fit-with-different-parameters" class="md-skip">
Skip to content
</a>
</div>
<div data-md-component="announce">
</div>
<div data-md-component="outdated" hidden>
</div>
<header class="md-header" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Header">
<a href="index.html" title="statsmodels 0.15.0 (+617)" class="md-header__button md-logo" aria-label="statsmodels 0.15.0 (+617)" data-md-component="logo">
<img src="_static/statsmodels-logo-v2-bw.svg" alt="logo">
</a>
<label class="md-header__button md-icon" for="__drawer">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg>
</label>
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
statsmodels 0.15.0 (+617)
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
Pitfalls
</span>
</div>
</div>
</div>
<label class="md-header__button md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
</label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
<label class="md-search__icon md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</label>
<nav class="md-search__options" aria-label="Search">
<button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg>
</button>
</nav>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix>
<div class="md-search-result" data-md-component="search-result">
<div class="md-search-result__meta">
Initializing search
</div>
<ol class="md-search-result__list"></ol>
</div>
</div>
</div>
</div>
</div>
<div class="md-header__source">
<a href="https://github.com/statsmodels/statsmodels/" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--! Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg>
</div>
<div class="md-source__repository">
statsmodels
</div>
</a>
</div>
</nav>
</header>
<div class="md-container" data-md-component="container">
<main class="md-main" data-md-component="main">
<div class="md-main__inner md-grid">
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href="index.html" title="statsmodels 0.15.0 (+617)" class="md-nav__button md-logo" aria-label="statsmodels 0.15.0 (+617)" data-md-component="logo">
<img src="_static/statsmodels-logo-v2-bw.svg" alt="logo">
</a>
statsmodels 0.15.0 (+617)
</label>
<div class="md-nav__source">
<a href="https://github.com/statsmodels/statsmodels/" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--! Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg>
</div>
<div class="md-source__repository">
statsmodels
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="install.html" class="md-nav__link">
<span title="/install.rst (reference label)" class="md-ellipsis">Installing statsmodels</span>
</a>
</li>
<li class="md-nav__item">
<a href="gettingstarted.html" class="md-nav__link">
<span title="/gettingstarted.rst (reference label)" class="md-ellipsis">Getting started</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_3" type="checkbox" id="__nav_3" checked>
<div class="md-nav__link md-nav__link--index ">
<a href="user-guide.html"><span title="/user-guide.rst (reference label)" class="md-ellipsis">User Guide</span></a>
<label for="__nav_3">
<span class="md-nav__icon md-icon"></span>
</label>
</div>
<nav class="md-nav" aria-label="User Guide" data-md-level="1">
<label class="md-nav__title" for="__nav_3">
<span class="md-nav__icon md-icon"></span>
<span title="/user-guide.rst (reference label)" class="md-ellipsis">User Guide</span>
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_3_1" type="checkbox" id="__nav_3_1" checked>
<div class="md-nav__link md-nav__link--index ">
<a href="user-guide.html#background"><span title="/user-guide.rst#background (reference label)" class="md-ellipsis">Background</span></a>
<label for="__nav_3_1">
<span class="md-nav__icon md-icon"></span>
</label>
</div>
<nav class="md-nav" aria-label="Background" data-md-level="2">
<label class="md-nav__title" for="__nav_3_1">
<span class="md-nav__icon md-icon"></span>
<span title="/user-guide.rst#background (reference label)" class="md-ellipsis">Background</span>
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="endog_exog.html" class="md-nav__link">
<span title="/endog_exog.rst (reference label)" class="md-ellipsis">endog, exog, what’s that?</span>
</a>
</li>
<li class="md-nav__item">
<a href="api-structure.html" class="md-nav__link">
<span title="/api-structure.rst (reference label)" class="md-ellipsis">Import Paths and Structure</span>
</a>
</li>
<li class="md-nav__item">
<a href="example_formulas.html" class="md-nav__link">
<span title="/example_formulas.rst (reference label)" class="md-ellipsis">Fitting models using R-<wbr>style formulas</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-nav__toggle md-toggle" data-md-toggle="toc" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc">
<span title="/pitfalls.rst (reference label)" class="md-ellipsis">Pitfalls</span>
<span class="md-nav__icon md-icon"></span>
</label>
<a href="#" class="md-nav__link md-nav__link--active">
<span title="/pitfalls.rst (reference label)" class="md-ellipsis">Pitfalls</span>
</a>
<nav class="md-nav md-nav--secondary">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#repeated-calls-to-fit-with-different-parameters" class="md-nav__link">
<span title="/pitfalls.rst#repeated-calls-to-fit-with-different-parameters (reference label)" class="md-ellipsis">Repeated calls to fit with different parameters</span>
</a>
</li>
<li class="md-nav__item">
<a href="#unidentified-parameters" class="md-nav__link">
<span title="/pitfalls.rst#unidentified-parameters (reference label)" class="md-ellipsis">Unidentified Parameters</span>
</a>
<nav class="md-nav" aria-label="Unidentified Parameters">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#rank-deficient-exog-perfect-multicollinearity" class="md-nav__link">
<span title="/pitfalls.rst#rank-deficient-exog-perfect-multicollinearity (reference label)" class="md-ellipsis">Rank deficient exog, perfect multicollinearity</span>
</a>
</li>
<li class="md-nav__item">
<a href="#incomplete-convergence-in-maximum-likelihood-estimation" class="md-nav__link">
<span title="/pitfalls.rst#incomplete-convergence-in-maximum-likelihood-estimation (reference label)" class="md-ellipsis">Incomplete convergence in maximum likelihood estimation</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#other-problems" class="md-nav__link">
<span title="/pitfalls.rst#other-problems (reference label)" class="md-ellipsis">Other Problems</span>
</a>
<nav class="md-nav" aria-label="Other Problems">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#insufficient-variation-in-the-data" class="md-nav__link">
<span title="/pitfalls.rst#insufficient-variation-in-the-data (reference label)" class="md-ellipsis">Insufficient variation in the data</span>
</a>
</li>
<li class="md-nav__item">
<a href="#true-parameter-outside-domain-of-model" class="md-nav__link">
<span title="/pitfalls.rst#true-parameter-outside-domain-of-model (reference label)" class="md-ellipsis">True parameter outside domain of model</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="user-guide.html#regression-and-linear-models" class="md-nav__link">
<span title="/user-guide.rst#regression-and-linear-models (reference label)" class="md-ellipsis">Regression and Linear Models</span>
</a>
</li>
<li class="md-nav__item">
<a href="user-guide.html#time-series-analysis" class="md-nav__link">
<span title="/user-guide.rst#time-series-analysis (reference label)" class="md-ellipsis">Time Series Analysis</span>
</a>
</li>
<li class="md-nav__item">
<a href="user-guide.html#other-models" class="md-nav__link">
<span title="/user-guide.rst#other-models (reference label)" class="md-ellipsis">Other Models</span>
</a>
</li>
<li class="md-nav__item">
<a href="user-guide.html#statistics-and-tools" class="md-nav__link">
<span title="/user-guide.rst#statistics-and-tools (reference label)" class="md-ellipsis">Statistics and Tools</span>
</a>
</li>
<li class="md-nav__item">
<a href="user-guide.html#data-sets" class="md-nav__link">
<span title="/user-guide.rst#data-sets (reference label)" class="md-ellipsis">Data Sets</span>
</a>
</li>
<li class="md-nav__item">
<a href="user-guide.html#sandbox" class="md-nav__link">
<span title="/user-guide.rst#sandbox (reference label)" class="md-ellipsis">Sandbox</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="examples/index.html" class="md-nav__link">
<span title="/examples/index.rst (reference label)" class="md-ellipsis">Examples</span>
</a>
</li>
<li class="md-nav__item">
<a href="api.html" class="md-nav__link">
<span title="/api.rst (reference label)" class="md-ellipsis">API Reference</span>
</a>
</li>
<li class="md-nav__item">
<a href="about.html" class="md-nav__link">
<span title="/about.rst (reference label)" class="md-ellipsis">About statsmodels</span>
</a>
</li>
<li class="md-nav__item">
<a href="dev/index.html" class="md-nav__link">
<span title="/dev/index.rst (reference label)" class="md-ellipsis">Developer Page</span>
</a>
</li>
<li class="md-nav__item">
<a href="release/index.html" class="md-nav__link">
<span title="/release/index.rst (reference label)" class="md-ellipsis">Release Notes</span>
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#repeated-calls-to-fit-with-different-parameters" class="md-nav__link">
<span title="/pitfalls.rst#repeated-calls-to-fit-with-different-parameters (reference label)" class="md-ellipsis">Repeated calls to fit with different parameters</span>
</a>
</li>
<li class="md-nav__item">
<a href="#unidentified-parameters" class="md-nav__link">
<span title="/pitfalls.rst#unidentified-parameters (reference label)" class="md-ellipsis">Unidentified Parameters</span>
</a>
<nav class="md-nav" aria-label="Unidentified Parameters">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#rank-deficient-exog-perfect-multicollinearity" class="md-nav__link">
<span title="/pitfalls.rst#rank-deficient-exog-perfect-multicollinearity (reference label)" class="md-ellipsis">Rank deficient exog, perfect multicollinearity</span>
</a>
</li>
<li class="md-nav__item">
<a href="#incomplete-convergence-in-maximum-likelihood-estimation" class="md-nav__link">
<span title="/pitfalls.rst#incomplete-convergence-in-maximum-likelihood-estimation (reference label)" class="md-ellipsis">Incomplete convergence in maximum likelihood estimation</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#other-problems" class="md-nav__link">
<span title="/pitfalls.rst#other-problems (reference label)" class="md-ellipsis">Other Problems</span>
</a>
<nav class="md-nav" aria-label="Other Problems">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#insufficient-variation-in-the-data" class="md-nav__link">
<span title="/pitfalls.rst#insufficient-variation-in-the-data (reference label)" class="md-ellipsis">Insufficient variation in the data</span>
</a>
</li>
<li class="md-nav__item">
<a href="#true-parameter-outside-domain-of-model" class="md-nav__link">
<span title="/pitfalls.rst#true-parameter-outside-domain-of-model (reference label)" class="md-ellipsis">True parameter outside domain of model</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content" data-md-component="content">
<article class="md-content__inner md-typeset" role="main">
<h1 id="pitfalls">Pitfalls<a class="headerlink" href="#pitfalls" title="Link to this heading">¶</a></h1>
<p>This page lists issues which may arise while using statsmodels. These
can be the result of data-related or statistical problems, software design,
“non-standard” use of models, or edge cases.</p>
<p>statsmodels provides several warnings and helper functions for diagnostic
checking (see this <a class="reference external" href="http://jpktd.blogspot.ca/2012/01/anscombe-and-diagnostic-statistics.html">blog article</a>
for an example of misspecification checks in linear regression). The coverage
is of course not comprehensive, but more warnings and diagnostic functions will
be added over time.</p>
<p>While the underlying statistical problems are the same for all statistical
packages, software implementations differ in the way extreme or corner cases
are handled. Please report corner cases for which the models might not work, so
we can treat them appropriately.</p>
<h2 id="repeated-calls-to-fit-with-different-parameters">Repeated calls to fit with different parameters<a class="headerlink" href="#repeated-calls-to-fit-with-different-parameters" title="Link to this heading">¶</a></h2>
<p>Result instances often need to access attributes from the corresponding model
instance. Fitting a model multiple times with different arguments can change
model attributes. This means that the result instance may no longer point to
the correct model attributes after the model has been re-fit.</p>
<p>It is therefore best practice to create separate model instances when we want
to fit a model using different fit function arguments.</p>
<p>For example, this works without problem because we are not keeping the results
instance for further use</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><code><span class="n">mod</span> <span class="o">=</span> <span class="n">AR</span><span class="p">(</span><span class="n">endog</span><span class="p">)</span>
<span class="n">aic</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">lag</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">11</span><span class="p">):</span>
<span class="n">res</span> <span class="o">=</span> <span class="n">mod</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">maxlag</span><span class="o">=</span><span class="n">lag</span><span class="p">)</span>
<span class="n">aic</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">res</span><span class="o">.</span><span class="n">aic</span><span class="p">)</span>
</code></pre></div>
</div>
<p>However, when we want to hold on to two different estimation results, then it
is recommended to create two separate model instances.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><code><span class="n">mod1</span> <span class="o">=</span> <span class="n">RLM</span><span class="p">(</span><span class="n">endog</span><span class="p">,</span> <span class="n">exog</span><span class="p">)</span>
<span class="n">res1</span> <span class="o">=</span> <span class="n">mod1</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">scale_est</span><span class="o">=</span><span class="s1">'mad'</span><span class="p">)</span>
<span class="n">mod2</span> <span class="o">=</span> <span class="n">RLM</span><span class="p">(</span><span class="n">endog</span><span class="p">,</span> <span class="n">exog</span><span class="p">)</span>
<span class="n">res2</span> <span class="o">=</span> <span class="n">mod2</span><span class="o">.</span><span class="n">fit</span><span class="p">(</span><span class="n">scale_est</span><span class="o">=</span><span class="n">sm</span><span class="o">.</span><span class="n">robust</span><span class="o">.</span><span class="n">scale</span><span class="o">.</span><span class="n">HuberScale</span><span class="p">())</span>
</code></pre></div>
</div>
<h2 id="unidentified-parameters">Unidentified Parameters<a class="headerlink" href="#unidentified-parameters" title="Link to this heading">¶</a></h2>
<h3 id="rank-deficient-exog-perfect-multicollinearity">Rank deficient exog, perfect multicollinearity<a class="headerlink" href="#rank-deficient-exog-perfect-multicollinearity" title="Link to this heading">¶</a></h3>
<p>Models based on linear models, GLS, RLM, GLM and similar, use a generalized
inverse. This means that:</p>
<ul class="simple">
<li><p>Rank deficient matrices will not raise an error</p></li>
<li><p>Cases of almost perfect multicollinearity or ill-conditioned design matrices might produce numerically unstable results. Users need to manually check the rank or condition number of the matrix if this is not the desired behavior</p></li>
</ul>
<p>Note: statsmodels currently fails on the NIST benchmark case for Filip if the
data is not rescaled, see <a class="reference external" href="http://jpktd.blogspot.ca/2012/03/numerical-accuracy-in-linear-least.html">this blog</a></p>
<h3 id="incomplete-convergence-in-maximum-likelihood-estimation">Incomplete convergence in maximum likelihood estimation<a class="headerlink" href="#incomplete-convergence-in-maximum-likelihood-estimation" title="Link to this heading">¶</a></h3>
<p>In some cases, the maximum likelihood estimator might not exist, parameters
might be infinite or not unique (e.g. (quasi-)separation in models with binary
endogenous variable). Under the default settings, statsmodels will print
a warning if the optimization algorithm stops without reaching convergence.
However, it is important to know that the convergence criteria may sometimes
falsely indicate convergence (e.g. if the value of the objective function
converged but not the parameters). In general, a user needs to verify
convergence.</p>
<p>For binary Logit and Probit models, statsmodels raises an exception if perfect
prediction is detected. There is, however, no check for quasi-perfect
prediction.</p>
<h2 id="other-problems">Other Problems<a class="headerlink" href="#other-problems" title="Link to this heading">¶</a></h2>
<h3 id="insufficient-variation-in-the-data">Insufficient variation in the data<a class="headerlink" href="#insufficient-variation-in-the-data" title="Link to this heading">¶</a></h3>
<p>It is possible that there is insufficient variation in the data for small
datasets or for data with small groups in categorical variables. In these
cases, the results might not be identified or some hidden problems might occur.</p>
<p>The only currently known case is a perfect fit in robust linear model estimation.
For RLM, if residuals are equal to zero, then it does not cause an exception,
but having this perfect fit can produce NaNs in some results (scale=0 and 0/0
division) (issue #55).</p>
<h3 id="true-parameter-outside-domain-of-model">True parameter outside domain of model<a class="headerlink" href="#true-parameter-outside-domain-of-model" title="Link to this heading">¶</a></h3>
<p>In some cases domain restrictions for parameters in a model might be
inconsistent with the data. In those cases, estimation might stop at
parameter values close to the boundary of the parameter space, but can slso
fail with runtime errors or produce nans during optimization.</p>
<p>Two examples:</p>
<p>Estimating a negative binomial model when the data is not overdispersed
relative to Poisson, that is the true model has the same dispersion as Poisson
or is underdispersed, is inconsistent with the overdispersion assumption of
the Negative Binomial distribution. The loglikelihood and its derivatives, as
implemented in statsmodels, cannot be evaluated for dispersion parameter at
zero dispersion or in a positive neighborhood of zero dispersion.</p>
<p>Zero inflated models currently use either Logit or Probit as model for
inflation. This means that no inflation is at the boundary of the parameter
space and zero deflation is outside the valid parameter space.
When the data has no zero inflation or is zero deflated, then the zero
inflation model will often fail in the optimization, or end up close to the
no inflation boundary.</p>
<hr>
<div class="md-source-file">
<small>
Last update:
Feb 19, 2025
</small>
</div>
</article>
</div>
</div>
</main>
<footer class="md-footer">
<nav class="md-footer__inner md-grid" aria-label="Footer" >
<a href="example_formulas.html" class="md-footer__link md-footer__link--prev" aria-label="Previous: Fitting models using R-style formulas" rel="prev">
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
</div>
<div class="md-footer__title">
<div class="md-ellipsis">
<span class="md-footer__direction">
Previous
</span>
Fitting models using R-style formulas
</div>
</div>
</a>
<a href="regression.html" class="md-footer__link md-footer__link--next" aria-label="Next: Linear Regression" rel="next">
<div class="md-footer__title">
<div class="md-ellipsis">
<span class="md-footer__direction">
Next
</span>
Linear Regression
</div>
</div>
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4Z"/></svg>
</div>
</a>
</nav>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-copyright">
<div class="md-footer-copyright__highlight">
© Copyright 2009-2025, Josef Perktold, Skipper Seabold, Jonathan Taylor, statsmodels-developers.
</div>
Created using
<a href="https://www.sphinx-doc.org/" target="_blank" rel="noopener">Sphinx</a>
7.3.7.
and
<a href="https://github.com/jbms/sphinx-immaterial/" target="_blank" rel="noopener">Sphinx-Immaterial</a>
</div>
<div class="md-social">
<a href="https://github.com/statsmodels/statsmodels/" target="_blank" rel="noopener" title="Source on github.com" class="md-social__link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><!--! Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg>
</a>
<a href="https://pypi.org/project/statsmodels/" target="_blank" rel="noopener" title="pypi.org" class="md-social__link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z"/></svg>
</a>
<a href="https://doi.org/10.5281/zenodo.593847" target="_blank" rel="noopener" title="doi.org" class="md-social__link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--><path d="M0 216C0 149.7 53.7 96 120 96h8c17.7 0 32 14.3 32 32s-14.3 32-32 32h-8c-30.9 0-56 25.1-56 56v8h64c35.3 0 64 28.7 64 64v64c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V216zm256 0c0-66.3 53.7-120 120-120h8c17.7 0 32 14.3 32 32s-14.3 32-32 32h-8c-30.9 0-56 25.1-56 56v8h64c35.3 0 64 28.7 64 64v64c0 35.3-28.7 64-64 64h-64c-35.3 0-64-28.7-64-64V216z"/></svg>
</a>
</div>
</div>
</div>
</footer>
</div>
<div class="md-dialog" data-md-component="dialog">
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"base": ".", "features": [], "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.config.lang": "en", "search.config.pipeline": "trimmer, stopWordFilter", "search.config.separator": "[\\s\\-]+", "search.placeholder": "Search", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version.title": "Select version"}, "version": {"provider": "mike", "staticVersions": null, "versionPath": "../versions-v3.json"}}</script>
<script src="_static/sphinx_immaterial_theme.f9d9eeeb247ace16c.min.js?v=8ec58cb5"></script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
</body>
</html>