我有两个测量相同未知变量的两种不同测量类型的数据帧(A,B)。我试图通过将测量线性回归到我精确知道的另一个变量(C)来对隐藏变量进行更精确的测量,然后将两者中的不确定性结合起来以减少测量中的不确定性。
所以(x1 * A0 + x2 * A1~C)和(y1 * B0 + y2 * B1~C)
A0 A1
2017-06-08 22:00:00 0.2 0.8
2017-06-08 22:15:00 0.7 0.2
2017-06-08 22:30:00 0.4 0.4
2017-06-08 22:45:00 0.6 0.3
B0 B1
2017-06-08 22:00:00 15 32
2017-06-08 22:15:00 50 10
2017-06-08 22:30:00 32 18
2017-06-08 22:45:00 41 11
C
2017-06-08 22:00:00 94
2017-06-08 22:15:00 113
2017-06-08 22:30:00 97
2017-06-08 22:45:00 109
这似乎是pymc3中的分层模型,所以我尝试了
with pm.Model() as model:
ACalFactor = pm.Lognormal('ACalFactor', mu = 0, sd = 1,\
shape = len(A.columns))
BCalFactor = pm.Cauchy('BCalFactor', alpha = 0, beta = 100,\
shape = len(B.columns))
AtoBStdDev = pm.HalfCauchy('BStdDev', 10)
BTotalStdDev = pm.HalfCauchy('BStdDev', 10)
AtoBEst = pm.Normal('AtoB', mu = A.multiply(ACalFactor), sd = AtoBStdDev,\
shape = len(B.Columns))
BtoTotalEst = pm.Normal('BtoTotal', mu = tt.dot(B, BCalFactor),\
sd = BTotalStdDev, observed = C)
但是这没用,所以我尝试了
with pm.Model() as model:
ACalFactor = pm.Lognormal('ACalFactor', mu = 0, sd = 1,\
shape = len(A.columns))
BCalFactor = pm.Cauchy('BCalFactor', alpha = 0, beta = 100,\
shape = len(B.columns))
AtoCStdDev = pm.HalfCauchy('BStdDev', 10)
BtoCStdDev = pm.HalfCauchy('BStdDev', 10)
AtoTotalEst = pm.Normal('AtoTotal', mu = tt.dot(A, ACalFactor), sd = AtoCStdDev,\
observed = C)
BtoTotalEst = pm.Normal('BtoTotal', mu = tt.dot(B, BCalFactor),\
sd = BTotalStdDev, observed = C)
首先是有办法让第一个工作。我认为它遵循的路线 P(C | A,B)= P(A | C,B)* P(C | B)/ P(A | B)
如果没有办法让第二个工作我认为如下 P(0 | A0,B0)= P(0 | A0)* P(0 | B0)
感谢您的帮助。这是我的第一篇文章,所以如果我没有做好试图解释问题或搞砸别的东西,我很抱歉。如果我这样做,请告诉我,我会确保不再犯错误。