如何实现联合hyerprior?

时间:2018-06-09 01:20:08

标签: pymc3

我试图从贝叶斯数据分析第三版重新创建结果。

第5章第3节涉及大鼠肿瘤。 a Hierarchical模型是合适的,所使用的hyperprior不是pymc3中包含的密度之一。

hyperprior是Private Sub btnCopyTimes_Click() ' Define variables Dim EnteredValue As Double, CheckCount As Long Dim IDToUpdate As String Dim qdef As QueryDef ' Grab ID IDToUpdate = Me.FINLDATA_ID.Value ' Prompt for new base time for ALL models EnteredValue = InputBox("Enter New Base Time for ALL models") CheckCount = DCount("*", "T_MODELS_LIST", _ "MODEL = " & Me.FINLDATA_MODEL_ID) If CheckCount >= 1 Then ' RUN UPDATE Set qdef = CurrentDb.QueryDefs("myUpdateQuery") qdef![BaseTimeParam] = EnteredValue ' BIND PARAMETERS qdef![IDParam] = IDToUpdate qdef.Execute dbFailOnError ' EXECUTE ACTION Else ' RUN APPEND Set qdef = CurrentDb.QueryDefs("myAppendQuery") qdef![IDParam] = IDToUpdate ' BIND PARAMETERS qdef![ModelParam] = Me.FINLDATA_MODEL_ID qdef![BaseTimeParam] = EnteredValue qdef.Execute dbFailOnError ' EXECUTE ACTION End If Set qdef = Nothing ' Refresh the form display Me.F_EDIT_ENTRIES_MODEL_SUB.Form.Requery End Sub 。这是我尝试使用pymc3。

a*b*(a+b)^-2.5

在此阶段,我收到了错误

import pymc3 as pm
with pm.Model() as model:

    def ab_dist(x):
        #Should be log density, from what I have read
        a = x[0]
        b = x[1]
        return a+b-5/2*(a+b)

    ab = pm.DensityDist('ab', ab_dist, shape = 2, testval=[2,2])

    a = ab[0]
    b = ab[1]

    theta = pm.Beta('theta',alpha = a,beta = b)

    Y= pm.Binomial('y', n = n, p = theta, observed = y)

我做错了什么?我是否正确实施了密度?

0 个答案:

没有答案