 # Trying to use a prior distribution inside a logarithm

I’m trying to model my data with an equation that has a logarithm:
`y = A+B*log10(x-C)`

x- is a predictor variable
A, B & C are parameters I want to predict with a posterior. The model works if I use a constant value for C, but once I replace it with a prior probability, it breaks down. (I even truncated the C prior distribution, below the minimum value of x so not to have a negative in the log10().)

MY CODE:

``````curve_model = pm.Model()
with curve_model:
# Define Prior Probabilities
A = pm.Normal('A', mu=7.4, sd=2)
B = pm.Normal('B', mu=-2, sd=2)
C = pm.TruncatedNormal('C', mu=34, sd=2, upper=38)

sd_y = pm.InverseGamma('t', mu=0.5, sd=0.25)
mu_y = A+B*np.log10(x - C)

# Write parameters for posterior
post_fatigue = pm.Normal('post_fatigue', mu=mu_y , sd=sd_y, observed=y)
``````

MY ERROR MSG:

``````ValueError: length not known: Elemwise{sub,no_inplace} [id A] ''
|TensorConstant{[38.5   38..47 93.443]} [id B]
|InplaceDimShuffle{x} [id C] ''
|ViewOp [id D] 'C'
|Elemwise{sub,no_inplace} [id E] ''
|TensorConstant{38} [id F]
|Elemwise{exp,no_inplace} [id G] ''
|C_upperbound__ [id H]
``````

I’m sure the problem has to do with getting the difference of a data set and a distribution. I just don’t know how to work around this.

Thanks!

This should work - what is the data type of `x`?

Hi I’m reading ‘x’ from a csv file. the class is: <class ‘numpy.float64’>

Thanks!

Oh, And I should probably mention that I have been ignoring warnings that I can’t run theano:

WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Users\Tazzy\Anaconda3\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
warnings.warn(“DeprecationWarning: there is no c++ compiler.”
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.

I understood that theano makes my computer run more efficiently, Is this something that is required or optional?

Thanks

We found a solution! We changed
mu_y = A+Bnp.log10(x - C)
to
mu_y = A+B
np.log10(x.to_list() - C)

And it worked  Glad you find a solution - I think the problem is likely that `x` is a pandas serie