Dependencies pymc3 v3.0rc2

Hi,

I’m trying to install pymc3 v3.0rc2 on Python v2.7 with Anaconda.
Since it is a pain to solve all the dependencies with Anaconda, I wanted to ask if somebody knows the dependencies for this pymc3 version.

Thank you :slight_smile:

Hey @_julian, I don’t have immediate advice. Just wanted to ask, out of curiosity, why do you want to install these specific pymc3/ python 2.7 versions?

1 Like

The test environments used in v3 are probably a good place to start. But I don’t think PyMC3 was tested on Python v2, so it might not work at all.

@jessegrabowski thanks for that hint!

In fact I found some pymc3 code in a jupyter notebook and I am trying to reproduce it:

import numpy as np
import pandas as pd
import datetime as dt
from pandas_datareader import data as DataReader
import yfinance as yf
yf.pdr_override()
import matplotlib.pyplot as plt
%matplotlib inline
  
np.random.seed(1000000) #Who wants to be a millionaire
  
start, end = dt.datetime(2014, 1, 1), dt.datetime(2015, 12, 31)
sp500 = DataReader.get_data_yahoo('^GSPC', start, end).loc[:,'Close']
  
returns = np.log(sp500[1:] / sp500[0:-1].values) # Calculate log returns
train, test = np.arange(0, 450), np.arange(451,len(returns))
n=len(train)

plt.plot(returns)

import pymc3 as pm
with pm.Model() as model:
    sigma = pm.Exponential('sigma', 1./.02, testval=.1)
    mu = pm.Normal('mu', 0, sd=5, testval=.1)
  
    nu = pm.Exponential('nu', 1./10)
    logs = pm.GaussianRandomWalk('logs', tau=sigma**-2, shape=n)
  
    #lam uses variance in pymc3, not sd like in scipy
    r = pm.StudentT('r', nu, mu=mu, lam=1/pm.exp(-2*logs), observed=returns.values[train]) 

I somehow managed to install pymc3.0r2 because the code dates from 2016 and I thought this would thus maybe be the right version, but I am still getting the error that the function pm.exp() does not exist. Also, the general result of this version is not the same as in the notebook.
I don’t know if there is some doc where I could find the version in which the function exp() does exist in pymc3?

1 Like

At a quick glance, this code should run fine on the latest version. Instead of debugging stuff on the old version, you should give this a try on the new version and see what errors you get.

The only obvious things I see are that you will need to change the testval argument to initval, and import pymc as pm instetad of pmyc3.

See here for a port to PyMC 5 of this model: Stochastic Volatility model — PyMC example gallery

1 Like