I have two dataframes (A, B) of two different measurement types measuring the same unknown variable. I am trying to get a more precise measurement on the hidden variable by linearly regressing the measurements to another variable that I know precisely (C), and then combining the uncertainty in both to reduce the uncertainty in the measurement.
So (x1*A0 + x2*A1 ~ C) and (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
This seems like a hierarchical model in pymc3 so I have tried
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)
but this didn't work so I tried
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)
First is there a way to make the first one work. I think it follows the lines of P(C|A,B) = P(A|C,B)*P(C|B)/P(A|B)
If not is there a way to make the second one work which I think follows P(0|A0,B0) = P(0|A0)*P(0|B0)
Thanks for the help. This is my first post so I am sorry if I didn't do a good job trying to explain the problem or messed something else up. Let me know if I did and I will make sure not to make the mistake again.