我正在尝试使用Statsmodel运行tweedie模型,并不断出现以下错误:
AttributeError: 'Tweedie' object has no attribute 'ndim'
formula = 'pure_premium ~ atfault_model + channel_model_DIR + channel_model_IA + CLded_model + credit_model_52778 + \
credit_model_c6 + package_model_Elite + package_model_LBO + package_model_Plus + package_model_Savers + \
package_model_Savers_Plus + Q("ds_fp_paid_in_full_eligiable-has discount") + ds_fp_paid_in_full_ineligable + \
Q("ds_pn_prior_insurance_eligable-has discount") + ds_pn_prior_insurance_ineligable + \
Q("ds_ip_advanced_purchase_eligiable-has discount") + ds_ip_advanced_purchase_ineligable + \
credit_model_c5 + ds_ad_affinity + ds_ak_alliance + \
ds_ly_loyalty_discount + ds_mo_multipolicy + ds_pf_performance + majorvio_model + \
(driver_age_model*marital_status_model) + minorvio_model + multi_unit_model + \
RATING_CLASS_CODE_MODEL + unit_drv_exp_model + Vintiles + safety_course_model + instructor_course_model + \
(class_model*v_age_model) + (class_model*cc_model) + state_model'
lost_cost_model = smf.ols(formula = formula, data = coll_df
, family = sm.families.Tweedie(link = sm.families.links.log, var_power = 1.5))
每个变量都是一个范畴的、浮点的或整型的
我不知道是什么原因造成的。你知道吗
ols
不带族,OLS
只是线性回归。你知道吗您需要使用广义线性模型,即
GLM
或glm
作为公式接口。GLM
在单参数指数族中包含多个族,并包含一系列链接函数。你知道吗其他几个模型相当于GLM,但基于不同的实现和其他选项。这些模型是为特定的族链接组合编写的,没有修改这些模型的选项。你知道吗
OLS
是具有高斯族和线性链接的GLMLogit
是具有二项式族、logit链接的GLM,仅适用于二进制响应变量。Proit
是具有二项式族、probit-link的GLM,仅适用于二进制响应变量。Poisson
是具有泊松族和日志链接的GLMNegativeBinomial
是GLM的一个更通用的版本,它具有负多项式族和log链接。discrete.NegativeBinomial
允许隐含方差函数的若干参数化,并将离散参数与平均参数联合估计为MLE。你知道吗相关问题 更多 >
编程相关推荐