#NEWLINE# def test_offset_exposure( self ) : #NEWLINE# #INDENT# np . random . seed ( 382304 ) #NEWLINE# endog = np . random . randint ( 0 , 10 , 100 ) #NEWLINE# exog = np . random . normal ( size = ( 100 , 3 ) ) #NEWLINE# exposure = np . random . uniform ( 1 , 2 , 100 ) #NEWLINE# offset = np . random . uniform ( 1 , 2 , 100 ) #NEWLINE# mod1 = GLM ( endog , exog , family = sm . families . Poisson ( ) , offset = offset , exposure = exposure ) . fit ( ) #NEWLINE# offset2 = ( offset + np . log ( exposure ) ) #NEWLINE# mod2 = GLM ( endog , exog , family = sm . families . Poisson ( ) , offset = offset2 ) . fit ( ) #NEWLINE# assert_almost_equal ( mod1 . params , mod2 . params ) #NEWLINE# mod1_ = mod1 . model #NEWLINE# kwds = mod1_ . _get_init_kwds ( ) #NEWLINE# assert_allclose ( kwds [ 'exposure' ] , exposure , rtol = 1e-14 ) #NEWLINE# assert_allclose ( kwds [ 'offset' ] , mod1_ . offset , rtol = 1e-14 ) #NEWLINE# mod3 = mod1_ . __class__ ( mod1_ . endog , mod1_ . exog , ** kwds ) #NEWLINE# assert_allclose ( mod3 . exposure , mod1_ . exposure , rtol = 1e-14 ) #NEWLINE# assert_allclose ( mod3 . offset , mod1_ . offset , rtol = 1e-14 )