![](/img/trans.png)
[英]Error while running statsmodels in colab “estimate_tweedie_power() missing 1 required positional argument: 'mu'”
[英]ndim Error with Statsmodels Tweedie Model
我正在嘗試使用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))
每個變量都是分類變量,浮點變量或整數。
我不確定是什么原因造成的。
ols
沒有一個家族, OLS
只是線性回歸。
您需要為公式接口使用廣義線性模型,即GLM
或glm
。 GLM
在一個參數指數族中包括多個族,並且包括一系列鏈接函數。
其他幾種模型等效於GLM,但基於不同的實現方式和其他選項。 這些模型是為特定的家庭鏈接組合編寫的,沒有更改它們的選項。
OLS
是具有高斯族和線性鏈接的GLM
Logit
是具有二項式族,logit鏈接的GLM,僅適用於二進制響應變量。
Proit
是具有二項式家族,probit鏈接的GLM,僅適用於二進制響應變量。
Poisson
是GLM,擁有Poisson家族和日志鏈接
NegativeBinomial
是具有NegativeBinomial系列和日志鏈接的GLM的更通用版本。 discrete.NegativeBinomial
允許對隱式方差函數進行幾個參數化,並與平均參數一起將色散參數估計為MLE。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.