Giter VIP home page Giter VIP logo

nyu-econ-370's Introduction

Quantitative Economics with Python


ECON-UA 370 (NYU, Spring 2016)

This course aims to teach quantitative economics and the computer language python. We use python to teach economics and economics to teach python.


Notices

Final Exam will be held as per the officially scheduled timetable on 12th May.

For those students who have conflicting exams or have 3 or more exams on the same day please send me an email. There is an alternative exam scheduled for 13th May from 2:00pm to 3:50pm. To attend on Friday you must be registered to sit this exam.

Alternative Exam Details

Date: 13th May 2016
Time: 2:00pm to 3:50pm
Location: Rm 736 [19 W. 4th Street, 7FL - Economics]

Solutions to Assignment #4 were effectively covered when we discussed the midterm solutions to the Lake Model question in class. Please consult your class notes.

Note To get the best rendering for notebooks it is best to use nbviewer. This can be done by prepending the notebook web address with http://nbviewer.jupyter.org/github/. An example is:

http://nbviewer.jupyter.org/github/mmcky/nyu-econ-370/blob/master/notebooks/notes-linear-algebra.ipynb

Please submit assignments to: [email protected] as a Jupyter notebook with your solutions.

For those that attended the Python Fundamentals Workshop. The solutions notebook has been posted to the notebooks folder.

Updates

  • Added comment on Solutions for Assignment #4 [10th May 2016]
  • Posted update to Solutions for Assignment #6 to incorporate the linear algebra discussed in class [09th May 2016]
  • Posted Solutions for Assignment #5 Pandas and Assignment #6 on Asset Pricing [04th May 2016]
  • Updated Assignment #6 Question #3 [26th April 2016]
  • Posted Asset Pricing Lectures 3 and 4 [26th April 2016]
  • Posted Asset Pricing Homework - Assignment #6 [22nd April 2016]
  • Added python-fundamentals-workshop-solutions notebook
  • Updated working with data lecture [19th April 2016]
  • Posted Asset Pricing - Lecture 2 notes. [15th April 2016]
  • Posted a copy of the midterm exam. [13th April 2016]
  • Asset Pricing - Lecture 1 notes have been posted to the lectures folder [13th April 2016]
  • Assignment #5 has been posted and is due Thursday 21st April Tuesday 26th April [13th April 2016]
  • Assignment #4 has been posted and is due Tuesday 05th April [26th March 2016]
  • Updated Lake Model worker dynamics lecture and posted some solutions for assignment #3 [24th March 2016]
  • Uploaded a python reference sheet [21st March 2016]
  • Uploaded some practice exercises for linear algebra (with some Python problems) [18th March 2016]
  • Updated the midterm date (09th March 2016)
  • Updated Linear State Space Models Notebook
  • Assignment #2 Solutions and general feedback have been posted
  • Assignment #1 Everyone that submitted Assignment #1 on time has recieved full marks. If you would like feedback on Assignment #1 please come and see me during my office hours in Rm 823 (Economics Faculty) or make an appointment if that time doesn't work. I have posted some general feedback to the assignments folder. (23-Feb-2016)
  • Assignment submission should now be made to: [email protected]
  • We have changed the way the mybinder container is constructed. For those who use mybinder please let me know if you have any issues. Thanks.
  • Assignment #2 has been posted (10-Feb-2016) [Due: Tue 16th February 2016 Thur 18th February 2016]
  • Updated Syllabus has been posted (02-Feb-2016)
  • Assignment #1 has been posted (30-Jan-2016) [Due: Tue 09th February 2016]

Topic Breakdown

Weeks Topics
Weeks 1 to 3 Python: Programming Fundamentals
Weeks 4 to 8 Linear Algebra, Linear State Space Models, Discrete Markov Chain, and the Lake Model
Week 9 Python: Object Oriented Programming
Week 10 McCall Search Model (Lake Model Extension)
Week 11 Python: Data Analysis and Manipulation
Week 12 Permanent Income Model
Week 13 to 14 Extension Topic

You can download the syllabus here

MyBinder Service

The MyBinder service launches a live programming environment in the Cloud and allows you to interact with the course notebooks. However the changes to these notebooks are temporary and do not persist next time you open the notebook. For these types of changes it is best to download the notebooks to your computer and run jupyter notebook in a terminal (or powershell in windows) in the folder that contains your notebook files.

To launch the MyBinder service click on the following badge:

Binder

Office Hours

Time Location
Zhen Huo Tuesdays 11:00am to 1:00pm Rm 724 (Economics Faculty)
Matthew McKay Tuesdays 11:00am to 1:00pm Rm 823 (Economics Faculty)

References

The main reference for this course is the online material:

nyu-econ-370's People

Contributors

mmcky 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

Watchers

 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

nyu-econ-370's Issues

Installing the quantecon package

To install the quantecon package, open a terminal (OS X or Linux) or command line window (Windows) and type:

pip install quantecon

This should then show successful installation. Then you can open python or Jupyter notebooks and start using the package by:

import quantecon as qe

Understanding Python variables - More in Depth

Python has a pretty clever automatic memory manager (depending on who you ask) that takes responsibility for managing python's memory use by allocating and de-allocating memory that is used to store objects. The question was asked today if:

'a' == 'a'

is comparing two instances of the data that makes up the character a in memory or if this operation is comparing the same object (physically in memory) and the variable created points to the same information that makes up the letter a.

As it turns out - this is comparing a variable that points the same information in memory. For some simple immutable values python caches them to reduce expensive operations associated with the underlying memory allocation.

In [1]: id('a')
Out[1]: 140045168580400

In [2]: var = 'a'

In [3]: id(var)
Out[3]: 140045168580400

Therefore in this case python caches the object that makes up the letter 'a' and points variables to it in the memory heap managed by python. For more complex objects this isn't necessarily the case.

In [8]: id(2**64)
Out[8]: 140045087723392

In [9]: var = 2**64

In [11]: id(var)
Out[11]: 140045087720712

In [12]: 2**64
Out[12]: 18446744073709551616

In [13]: var
Out[13]: 18446744073709551616

While the values are the same, these objects do not share the same memory id.

Further Reading

http://foobarnbaz.com/2012/07/08/understanding-python-variables/

What is a ``stackoverflow``?

Great Question!

Not Part of the Course

A stack overflow is usually used in reference to the C programming language and describes a condition whereby a program overflows the C memory stack. This usually involves a program crash condition as the program is trying to access or use memory it is not permitted to do so.

This is related to the infinite or very deep recursion problem as it is a common cause of the stack overflow condition. Eventually the computer would run out of space on the stack and enter an overflow condition. The stack is a piece of memory that is reserved for the use of local variables and function returns.

Python puts protections in place to prevent this from happening - but you can actually alter that behavior using:

import sys
sys.setrecursionlimit(N)  #Where N is larger than what your system can handle (Depents on Hardware)

But in most cases this is generally a bad idea.

Using git and getting updates to the course repo on your machine ...

To get the course files you may use the GitHub page and download the raw files to your computer when they get updated.

Not Required - this is for students interested in Git which is not a requirement for this course.

Another way is to use git which is a version control application to retrieve the files. This also has the added benefit of being able to retrieve updates to the course repository easily. Git is installed on Linux (usually by default) and OS X. But it is not installed by default on Windows and would require installation.

git clone https://github.com/mmcky/nyu-econ-370.git

will fetch a copy of the entire repo and save it to your computer in the folder: nyu-econ-370/

To get updates

git pull origin master

will pull the latest changes into your repo.

Note: If you make changes to files within the repo - you may experience merge conflicts if I update older files.

Downloading Jupyter notebooks from GitHub

When you download an ipynb file using the RAW button in GitHub it displays the text int the browser. This is json code and contains all of the jupyter notebook cells. You can copy this text into a file and name it with the extension ipynb and it will contain the notebook when using it with Jupyter.

This is a little clunky so another options is:

  1. Launch an instance of the mybinder service
  2. Navigate to the notebook of interest
  3. Right Click and select Download linked file as

Assignment Submissions

Hi, is there a course staff mailing list where we would send our assignments? If not, which emails ID(s) would you prefer we sent the assignments to?

Downloading Raw Files from GitHub

To download a file from GitHub, such as the assignment PDF.

  1. Go to the assignments/ folder
  2. Click on the assignment that you want (i.e. assignment-1.pdf)
  3. Click on the RAW button.

This will download the PDF to your local computer.

Issues importing data_reader

If you are having issues with the following import

from pandas_datareader import wb,data

you can fix this by updating your anaconda distribution to the latest or issuing the following command (on the command line) to make sure the package is installed

conda install pandas-datareader

Assignment #6 Question 4

In Assignment #6 Question 4 we are asked about returns and tasked with showing that:
screen shot 2016-05-01 at 9 55 14 pm

Mathematically though isn't that asking to prove equality between a vector or scalar on the left and a matrix on the right? Any help would be appreciated...

Assignment Submissions ... Printing Jupyter Notebooks

For those of you using Jupyter notebooks for homework assignments - it is possible to use Jupyter to convert your document to LaTeX and then to PDF but this will require the installation of:

  1. LaTeX - TexLive (Windows or Linux) or MacTeX (OS x)
  2. Pandoc - Utility for converting between document types.

An easier route is to use your operating systems print feature and export it as a PDF

  1. OS X = Select File on the OS menubar (not Jupyter's menu bar) and then Export as PDF ...
  2. Windows = Select File on the OS menubar (not Jupyter's menu bar) and the Print .. or use Ctrl + P. Then Change Printer destination to Save as PDF. This worked using Chrome on Windows 7 but other versions may have slightly different wording.

If you have trouble printing it out then please submit the assignment via email to me before the class.

Note: If you want to setup LaTex and Pandoc - I am happy to assist during the student consultation hours next Tuesday.

LaTeX resources for writing Math in Jupyter

Writing math in Jupyter notebook markdown cells is fairly straight forward once you know the LaTeX commands. Below are some links to resources that will help you learn LaTeX. Once you have specified the math with LaTex then you may enter it into the Jupyter markdown type cell using $ ... $ for inline math and $$ .... $$ for display type formulae.

Checkout the demo notebooks for some examples. You can see the markdown by double clicking on the markdown cells.

Resources:

  1. https://en.wikibooks.org/wiki/LaTeX/Mathematics
  2. http://jupyter-notebook.readthedocs.org/en/latest/notebook.html#markdown-cells

Accessing Python object information in Jupyter

One of the great features of Jupyter is the live object inspection to obtain information about functions and methods.

To see what functions / methods are available through the objects interface you can:

import numpy as np
np.<tab> #Use the tab key in place of <tab>

To obtain the function signature or the parameter definitions you can:

import numpy as np
np.array(<shift>+<tab> #Replace <shift>+<tab> with the key combination after the open bracket

To get the full docstring:

import numpy as np
np.array(<shift>+<tab>+<tab> #Replace <shift>+<tab> plust another <tab> with the key combination after the open bracket to display more of the docstring

Another way to access this information is using the ? character in Jupyter

import numpy as np
np.array?

then execute the statement to obtain an information window at the bottom of your browser.

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.