Reputation: 1
I am trying to work with some insurance data to model likelihood of the claims. I am getting a value error when I try to run fit a Poisson GLM model with log link.
This is the sample code I used:
df = pd.DataFrame({'target': [225,248,338,563,270,297,405,675,428,470,641,1069,788,866,1181,1969],
'var1': ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'C', 'C', 'C', 'C', 'D', 'D', 'D', 'D'],
'var2': ['X', 'Y', 'Z', 'P', 'X', 'Y', 'Z', 'P', 'X', 'Y', 'Z', 'P', 'X', 'Y', 'Z', 'P'],
'offset': [250,1423,324,5245,135,1345,13145,234,754,2352,355,675,255,245,42,234]})
Model = smf.glm(formula='target ~ var1',
offset = df['offset'],
data=df,
family=sm.families.Poisson(link=sm.families.links.log()))
fit = Model.fit()
RuntimeWarning: overflow encountered in exp
return np.exp(z)
ValueError: NaN, inf or invalid value detected in weights, estimation infeasible.
Upvotes: 0
Views: 148