statsmodels Tweedie模型的ndim错误

问题描述 投票:0回答:1

我正在尝试使用Statsmodel运行tweedie模型并继续收到以下错误:

AttributeError:'Tweedie'对象没有属性'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))

每个变量都是分类变量,浮点数或整数。

我不确定是什么原因造成的。

python statsmodels
1个回答
1
投票

ols不带一个家庭,OLS只是线性回归。

您需要使用广义线性模型,即GLMglm作为公式接口。 GLM包含一个参数指数族中的几个族,并包括一系列链接函数。

其他几个模型等同于GLM,但基于不同的实现和其他选项。这些模型是针对特定的系列链接组合编写的,没有选项可以更改它们。

OLS是具有高斯族和线性链接的GLM Logit是GLM,具有二项式族,logit链接,仅用于二元响应变量。 Proit是具有二项式族,概率链接的GLM,仅用于二元响应变量。 Poisson是具有泊松族和日志链接的GLM NegativeBinomial是一个更通用的GLM版本,带有NegativeBinomial系列和日志链接。 discrete.NegativeBinomial允许隐含方差函数的几个参数化,并将平均参数与平均参数一起估计为MLE。

© www.soinside.com 2019 - 2024. All rights reserved.