Statsmodels Tweedie 模型的 ndim 错误

ndim Error with Statsmodels Tweedie Model

我正在尝试 运行 带有 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只是线性回归。

公式接口需要使用广义线性模型,即GLMglmGLM 在单参数指数族中包含多个族,并包含一系列 link 函数。

其他几个模型等同于 GLM,但基于不同的实现和其他选项。这些模型是为特定的系列-link 组合编写的,没有更改这些组合的选项。

OLS 是具有高斯族和线性 link
的 GLM Logit 是具有二项式族的 GLM,logit link 并且仅适用于二元响应变量。
Proit 是具有二项式族的 GLM,probit link 并且仅适用于二元响应变量。
Poisson 是具有泊松族的 GLM 并且对数 link
NegativeBinomial 是具有 NegativeBinomial 系列和对数 link 的 GLM 的更通用版本。 discrete.NegativeBinomial 允许对隐含方差函数进行多个参数化,并将离散参数与均值参数一起估计为 MLE。