Hey folks,
I am absolutely new into pymc and bayesian statistics, so please bare with me for my potentially stupid question beforehand
I am currently working over an example from a book modelling the sharpe ratio (mean/std) of an asset with the pymc3 package, which is not compatible anymore with the new version of pymc.
The author models the sharpe the following:
mean_prior = data.stock.mean()
std_prior = data.stock.std()
std_low = std_prior / 1000
std_high = std_prior * 1000
with pm.Model() as sharpe_model:
mean = pm.Normal('mean', mu=mean_prior, sigma=std_prior)
std = pm.Uniform('std', lower=std_low, upper=std_high)
nu = pm.Exponential('nu_minus_two', 1 / 29, testval=4) + 2.
returns = pm.StudentT('returns', nu=nu, mu=mean, sigma=std, observed=data.stock)
returns.mean()
sharpe = returns.distribution.mean / returns.distribution.variance ** .5 * np.sqrt(252)
pm.Deterministic('sharpe', sharpe)
However, this yields the error: AttributeError:
'TensorVariable' object has no attribute 'distribution'
I already tried to solve this by changing the sharpe definition to:
sharpe = returns.mean() / returns.std() * np.sqrt(252)
Which does not lead to an error anymore, however the sharpe is then not a distribution anymore:
How can this be properly fixed with the new pymc version? Feel also free to correct potentially wrong wordings of mine
Best,
D