Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ef0950c
DOC: GLM families base class
Feb 25, 2017
3d9d609
SUMM/FAQ: review of GLM families - scale in loglike, deviance and res…
Feb 25, 2017
1543010
SUMM/FAQ: review of GLM families - refactor _clean()
Feb 25, 2017
ab77df6
SUMM/FAQ: review of GLM families - scale, deviance, resid_dev, resid_…
Feb 25, 2017
a3806c6
SUMM/FAQ: review of GLM families - fixes for binomial family
Mar 7, 2017
d44eb2a
ENH: Add var_weights to GLM
thequackdaddy Jan 30, 2017
e8b0480
resid fixes and fixed corr_fact
thequackdaddy Feb 3, 2017
8fe4022
updated tests, add gamma/gaussian checks, misc fixes
thequackdaddy Feb 7, 2017
560d997
remove some straggling freq_weights
thequackdaddy Feb 7, 2017
f2313d3
Matched vs. R using some trickery...
thequackdaddy Feb 9, 2017
20b9cca
Changed some tests to be more appropriate data, added bfgs comparison
thequackdaddy Feb 9, 2017
888248e
compare irls vs. gradient for var_weights
thequackdaddy Feb 12, 2017
8b3630f
Add repeated vs. aggregate and repeated vs. average test
thequackdaddy Feb 12, 2017
21f12c0
Added tweedie comparison for var_weights and exposure, changed long .…
thequackdaddy Feb 14, 2017
d267bba
This test was taking up too much memory
thequackdaddy Apr 14, 2017
a7c1176
Add binomial test, notebook demonstrating weights.
thequackdaddy Apr 15, 2017
7631bba
Consistency changes to notebook
thequackdaddy Apr 18, 2017
3c6a6c6
Weight documentation
thequackdaddy Apr 18, 2017
044e2e6
Binomial var weights comparing var_weights vs. 2d
thequackdaddy May 23, 2017
35c21fb
Add a test for Gaussian/Identity vs. WLS
thequackdaddy May 25, 2017
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
890 changes: 890 additions & 0 deletions examples/notebooks/glm_weights.ipynb

Large diffs are not rendered by default.

660 changes: 328 additions & 332 deletions statsmodels/genmod/families/family.py

Large diffs are not rendered by default.

176 changes: 131 additions & 45 deletions statsmodels/genmod/generalized_linear_model.py

Large diffs are not rendered by default.

133 changes: 133 additions & 0 deletions statsmodels/genmod/tests/results/res_R_var_weight.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# This file auto-generated by test_get_R_tweedie_var_weight.R
# Using: R version 3.3.2 (2016-10-31)
import numpy as np
import pandas as pd
import os
path = os.path.abspath(__file__)
dir_path = os.path.dirname(path)


class Bunch(dict):
def __init__(self, **kw):
dict.__init__(self, kw)
self.__dict__ = self

res = dict()
res['params'] = np.array([0.74699331283637471213, -0.031592165334818442246, -0.021959412079720418837,
])
res['bse'] = np.array([0.25438368514036063806, 0.011629899831763350002, 0.011034604276375986273,
])
res['deviance'] = 45399.238887
res['ll'] = np.nan
res['resids_colnames'] = ['resid_response', 'resid_pearson', 'resid_deviance', 'resid_working']
csv_path = dir_path + '/results_tweedie_aweights_nonrobust.csv'
resids = np.array(pd.read_csv(csv_path))
res['resids'] = resids
results_tweedie_aweights_nonrobust = Bunch(**res)

res = dict()
res['params'] = np.array([4.3171222670686564271, -0.0388351754897242607, 0.54097404980660868112,
1.0560051462982855686, ])
res['bse'] = np.array([0.80693035376645061429, 0.013827354415503832763, 0.18432033391771765474,
0.18638491744499574576, ])
res['deviance'] = 28.440959
res['ll'] = -301.601118
res['resids_colnames'] = ['resid_response', 'resid_pearson', 'resid_deviance', 'resid_working']
res['resids'] = np.array([-6.0158828837706774806, -5.0064618231514179669, -5.5825299706057069926,
-6.951199947152929326, -4.5194555791952382151, -1.5575952697096662192,
-1.4915816791495473126, -2.8827914705025312614, -0.51945557919523821511,
0.11720852949746873861, -1.951199947152929326, -3.1808072290002549209,
0.24507819004189634882, 2.143181493070869692, 0.81919277099974507905,
5.2513574112015222184, 4.6547413107796593579, 5.8191927709997450791,
13.805056939001625338, 13.048800052847070674, -3.5461655336576232145,
-4.3171742548272717954, -6.540106573585148908, -5.6336912403283747608,
-9.2050394870744334241, -1.0510357669008367765, 1.4079973165214738628,
-3.4735049813672809194, 6.4538344663423767855, 0.52649501863271908064,
4.78682749182548406, 8.459893426414851092, 2.2438400255702184438,
14.907031306903792967, -19.462143015176206262, -16.470421423828963015,
-3.9684071597882955018, -13.143293042213230137, 1.338051623873866447,
-5.9189306552854752397, -0.46214301517620626214, 4.4406584534705366707,
-5.4161390999132805746, 7.5077293049191702323, 12.031592840211704498,
14.598574689109778291, 1.5838609000867194254, 10.391659880035845731,
-1.4851751347187072128, -0.8335126353179201919, -0.73623579362651225821,
-0.69852881904374664046, -0.5304864304042951062, -0.62668991451852917862,
-0.22977168783693979748, -0.36570693025306583168, -0.060972860808590170767,
0.014868911595094706432, -0.43844116716559600189, -0.28448815580596237274,
0.022787538056759808203, 0.41912332661394285926, 0.073267766291056440897,
1.7399635543130052007, 0.44993957624567232356, 0.520462668912329951,
1.6845824109142475411, 1.3112790539979426452, -0.83064421675569677372,
-0.41844541423804315627, -0.48301736312356513547, -0.38498087378000173109,
-0.47930333563071819691, -0.19501953749310727004, 0.21037977265236618152,
-0.18802631037644032541, 0.67606563531583585558, 0.028500006856508913744,
0.70357919510445188216, 0.62480257304022390752, 0.10810477604405059615,
0.87211481952369651616, -0.76435604825470426782, -1.3913258626323412592,
-0.18925649094598953615, -0.40889690502315273468, 0.059043979876129033812,
-0.33157319493773851349, -0.040585083378283849653, 0.18848822428675610086,
-0.16208153442619993578, 0.30653463692229510063, 0.57379622345778502623,
1.682526147248276871, 0.047398081967250066393, 0.36323882603675039515,
-2.5581754807345316038, -1.3851521395995887165, -1.0922123776889431923,
-1.0005518816044858266, -0.67167201537642184928, -0.69718647578569359347,
-0.25018637430918522213, -0.42317194136067926014, -0.062258126468306550227,
0.014795849411792027367, -0.47090072350586481553, -0.31707718488207037311,
0.022616712441591454996, 0.38940961297582005196, 0.071551164563882815872,
1.4232712112628336243, 0.39602447458757228382, 0.45043976939937618864,
1.1807262355942678145, 0.97311662165619994269, -0.9638708579427172074,
-0.4972022256126572004, -0.59452270989825062308, -0.44971332720853524068,
-0.58870075463517512748, -0.20099628475877281963, 0.20241883445549771481,
-0.20130092354682338485, 0.56500703029217991258, 0.028233670647681306798,
0.64093348288311413619, 0.52804594147321337605, 0.10443781856325348723,
0.7000658656634727306, -1.1671137424855801967, -1.8740944543642834574,
-0.20271679250264607042, -0.48346236705841011405, 0.057920367594102330211,
-0.35546257743250814221, -0.040833258826503134042, 0.17779833837362837845,
-0.1717727874767913665, 0.27984395675072842868, 0.49052124515619260903,
1.3835988443962714545, 0.046669269075347442899, 0.326727616856562042,
-0.85746626382358437368, -0.8335126353179201919, -0.73623579362651225821,
-0.69852881904374664046, -0.5304864304042951062, -0.28026424993539272856,
-0.22977168783693979748, -0.36570693025306583168, -0.060972860808590170767,
0.014868911595094706432, -0.19607685078332426354, -0.28448815580596237274,
0.022787538056759808203, 0.24198096544421138221, 0.073267766291056440897,
0.77813535716320536562, 0.44993957624567232356, 0.520462668912329951,
1.6845824109142475411, 1.3112790539979426452, -0.37147538675656155416,
-0.41844541423804315627, -0.48301736312356513547, -0.38498087378000173109,
-0.47930333563071819691, -0.087215388555031359008, 0.12146281837289588101,
-0.18802631037644032541, 0.67606563531583585558, 0.028500006856508913744,
0.31465018156162832819, 0.62480257304022390752, 0.10810477604405059615,
0.87211481952369651616, -0.76435604825470426782, -0.62221984153988985078,
-0.18925649094598953615, -0.40889690502315273468, 0.059043979876129033812,
-0.19143387335336761734, -0.018150201061267901698, 0.18848822428675610086,
-0.16208153442619993578, 0.30653463692229510063, 0.57379622345778502623,
0.75244856783359348462, 0.047398081967250066393, 0.36323882603675039515,
]).reshape((48, 4, ), order="F")
results_gamma_aweights_nonrobust = Bunch(**res)

res = dict()
res['params'] = np.array([0.019083886843747652901, 0.93993818512595395109, ])
res['bse'] = np.array([0.021677623131071667439, 0.82525358247654523325, ])
res['deviance'] = 1248.273065
res['ll'] = -52.674985
res['resids_colnames'] = ['resid_response', 'resid_pearson', 'resid_deviance', 'resid_working']
res['resids'] = np.array([32.059654151566597591, 3.3448403473353636173, 4.0197139246301958337,
-0.28159357589479405704, -1.6667828465428264906, 0.1388051302989401492,
-0.18150653007472383749, -2.9789626413378913483, -1.2529678508058896824,
-3.7054159516968709909, -1.0424256172378543184, -0.88813364418120310795,
-3.7241309774078530381, -1.3985915441086769206, -0.94066651909256271402,
-0.7629053132675633897, -1.0174777779460506544, 32.059654151566597591,
4.7303185831744052336, 6.96234874935159187, -0.56318715178958811407,
-3.7270397486003603582, 0.27761026059788029841, -0.31437853199495013889,
-4.2128893691828244172, -1.2529678508058896824, -5.2402494931233247755,
-1.8055341321673108457, -1.7762672883624062159, -8.3274100225966929401,
-2.7971830882173538413, -1.62928220404727786, -1.0789110408294828591,
-1.0174777779460506544, 32.059654151566597591, 4.7303185831744052336,
6.96234874935159187, -0.56318715178958811407, -3.7270397486003603582,
0.27761026059788029841, -0.31437853199495013889, -4.2128893691828244172,
-1.2529678508058896824, -5.2402494931233247755, -1.8055341321673108457,
-1.7762672883624062159, -8.3274100225966929401, -2.7971830882173538413,
-1.629282204047278082, -1.0789110408294828591, -1.0174777779460506544,
6.4893542142870010991, 0.5914670058447101253, 2.0298652677641753073,
-0.065768403960654975293, -0.35715886111512273882, 0.074578504679219670415,
-0.083202377610351055393, -0.59830990026015096195, -0.556141025429058522,
-0.787478936981250488, -0.5103860862495521733, -0.47037647304163465733,
-0.78832085630515191799, -0.58308866615653698329, -0.48471311780676745729,
-0.43275456005831103301, -0.50433159119200920983, ]).reshape((17, 4, ), order="F")
results_gaussian_aweights_nonrobust = Bunch(**res)

Loading