Skip to content

Commit

Permalink
change file names to be more descriptive (in my opinion)
Browse files Browse the repository at this point in the history
  • Loading branch information
aflaxman committed May 16, 2011
1 parent dc02c68 commit 603112c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
File renamed without changes.
8 changes: 4 additions & 4 deletions run_analysis1.py → fit.py
Original file line number Diff line number Diff line change
@@ -1,18 1,18 @@
import pymc as mc
import analysis1
reload(analysis1)
import model
reload(model)
import pylab as pl
#from pymc import Matplot
import Matplot
reload(Matplot)

# Generate reasonable initial values by maximizing posterior with
# variances held fixed
M = mc.MAP([analysis1.B, analysis1.U, analysis1.y_i])
M = mc.MAP([model.B, model.U, model.y_i])
M.fit(method='fmin_powell', verbose=0)

# Sample from full posterior distribution
M = mc.MCMC(analysis1)
M = mc.MCMC(model)
M.use_step_method(mc.AdaptiveMetropolis, [M.B, M.U, M.var_e1, M.var_u])
M.sample(iter=40000, burn=20000, thin=20, verbose=0)

Expand Down
12 changes: 6 additions & 6 deletions analysis1.py → model.py
Original file line number Diff line number Diff line change
@@ -1,14 1,14 @@
import pylab as pl
import pymc as mc

run1 = pl.csv2rec('run1.csv')
data = pl.csv2rec('data.csv')

## Design matrix for intercept and intervention effect
X = [[1., t_ij] for t_ij in run1.treat]
X = [[1., t_ij] for t_ij in data.treat]

## Design matrix for cluster effect
Z = pl.zeros([len(run1), 10])
for row, j in enumerate(run1.j):
Z = pl.zeros([len(data), 10])
for row, j in enumerate(data.j):
if j <= 10:
Z[row, j-1] = 1.

Expand All @@ -28,5 28,5 @@ def y_hat(B=B, X=X, Z=Z, U=U):
return pl.dot(X,B) pl.dot(Z,U)

@mc.stochastic(observed=True)
def y_i(value=run1.y, mu=y_hat, tau=tau_e1):
return mc.normal_like(value,mu,tau[run1.treat])
def y_i(value=data.y, mu=y_hat, tau=tau_e1):
return mc.normal_like(value,mu,tau[data.treat])

0 comments on commit 603112c

Please sign in to comment.