Coder Social home page Coder Social logo

pysd-cookbook's People

Contributors

enekomartinmartinez avatar jamesphoughton avatar jonititan avatar philippschw avatar sleepingagain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pysd-cookbook's Issues

how to solve the issue

Hi , James

When I use 'pysd' library to write some program, it shows this error as below. How can I solve this isssue. Thanks.

%pylab inline
import pysd

model = pysd.read_vensim('./A4.mdl')
stocks = model.run()

_

Populating the interactive namespace from numpy and matplotlib

File "./A4.py", line 66
@cache('step')
^
SyntaxError: invalid syntax

_

Add source file name to bottom of translated `.rst` files

When we translate the notebooks to rst, before building the documentation, we should add the name of the source file, with a link, to the bottom of the page. That way, if users are reading along on the web docs, they can quickly go to the source and try it for themselves.

Bug : Parallel Model Fitting Example

Hi,
I am getting error in cookbook example Parallel Model Fitting

TypeError: ("run() got an unexpected keyword argument 'rtol'", 'occurred at index 0')

When I run the code


param_names = ['dec_%i_loss_rate'%i for i in range(1,10)]

def error(param_vals, measurements):
    predictions = model.run(params=dict(zip(param_names, param_vals)),
                            initial_condition=(2000,measurements['2000']),
                            return_timestamps=2010, rtol=1).loc[2010]

    errors = predictions - measurements['2010']
    return sum(errors.values[1:]**2) #ignore first decade: no birth info

def fit(row):
    res = scipy.optimize.minimize(error, args=row,
                                  x0=[.05]*9,
                                  method='L-BFGS-B');
    return pd.Series(index=['dec_%i_loss_rate'%i for i in range(1,10)], data=res['x'])

%%capture
county_params = data.apply(fit, axis=1)

Model Comparison Example

We can use system dynamics to identify tests between theories if we formalize those theories as simulations, and then find the regions in the parameter space that maximize the observable difference between the theories, and then design an experiment to operate in those parameter regimes.

A nice case study for this type of test could be Young, H.Peyton. 2009. “Innovation Diffusion in Heterogeneous Populations : Contagion , Social Influence , and Social Learning.” American Economic Review 99(5):1899–1924. which compares three different types of adoption under social influence.

Move new modules to the 'ingredients' section

If we're introducing a module that is outside of the standard python stack - e.g. a tool for distributed computing, or an optimization package - we should consider these to be ingredients in the recipes.

Partial Model Testing Example

This could be an interesting paper to replicate for demonstrating how one might formalize partial model tests for asserting bounded rationality in decision rules:

Sterman, John D. 1985. “A Behavioral Model of the Economic Long Wave.” Journal of Economic Behavior and Organization 6(February 1984):17–53.

Issues with Defect Rate surrogation model

The link polarity from 'Time allocated per unit' to 'Fulfillment Rate' should be negative, as the parameter is in the denominator.

Also, there really should be comments and units in this model.

Demo Creating Bifurcation Diagrams

Could use the economic cycle entrainment model in Mosekilde, Erik, Erik Reimer Larsen, John D. Sterman, and Jesper Skovhus Thomsen. 1992. “Nonelinear Mode-Interaction in the Macroeconomy.” Annals of Operations Research 37:185–215.

Distributed Calculations

Optimization, Monte Carlo, etc. are all analyses that could benefit from running models in parallel.

We have a basic demonstration of parallel model fitting, where we fit the model independently to a lot of datasets: http://pysd-cookbook.readthedocs.org/en/latest/analyses/fitting/Massively_Parallel_Fitting.html

But we should show how these can be distributed across multiple computers. This is facilitated by the fact that pysd and its dependencies are pure-python, and can be pickled and distributed.

Here are a few resources for parallel computing in python:

Distribution frameworks:

  • multiprocessing
    • Part of standard python library
    • Runs easily in interactive mode
    • Basically limited to the cores on one host
  • celery
  • scoop
    • + Really clean API
    • - Doesn't play well with ipython/jupyter
  • jug

Design of Experiments for model selection

Analyze a pair of models together, in such a way that you find the places where their predictions diverge. This is the place to conduct an experiment, as it will give the biggest differentiator between the models.

Because the advance of science is much more economical when we can explicitly eliminate the most likely alternative theories, and because formulating the alternative theories and deriving their consequences is preeminently a theoretical task, the central gift of the great methodologist is his facility at formulating and deriving the consequences of alternative theories in such a way that the observations can actually be made to decide the question. (Stinchcombe 1968)

Formal models should excel at this task, as they are able to actually compare the implications of each formalized theory across a range of parameters.

Going further, If you have an understanding of the uncertainties of the parameters, then you can derive a distribution for the predicted values at that point in the parameters space for each model. Then you have the likelihood of getting a predicted value given that the model is correct (given that one of your models is correct). This is a good setup for model selection using MCMC.

Could show that by preferentially conducting experiments at the place where models diverge, you improve the tightness of your parameter estimation in the MCMC...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.