Key Word(s): ??
In [0]:
!pip install xarray==0.16.0
In [1]:
import pandas as pd
import numpy as np
import pymc3 as pm
from matplotlib import pyplot
%matplotlib inline
In [2]:
df = pd.read_csv('data3.csv')
In [0]:
### edTest(test_pm_model) ###
np.random.seed(109)
with pm.Model() as model:
# prior
alpha = pm.Normal('alpha', mu=0, tau=1000)
beta = pm.Normal('beta', mu=0, tau=1000)
# likelihood
# Next statement creates the expected value of mu_vec of the
# outcomes, specifying the linear relationship.
# mu_vec is just the sum of the intercept alpha and the product of
# the coefficient beta and the predictor variable.
mu_vec = pm.Deterministic('mu_vec', ____)
tau_obs = pm.Gamma('tau_obs', 0.001, 0.001)
obs = pm.Normal(_______) #Parameters to set: name, mu, tau, observed
trace = pm.sample(2000, tune=2000, chains=2)
pm.traceplot(trace, var_names=['alpha','beta','tau_obs'], compact=False);
In [0]:
#posterior means
np.mean(trace['alpha']),np.mean(trace['beta']), np.mean(trace['tau_obs'])
In [0]: