This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
You need to fill in your API key from google below. Note that querying | |
supported languages is not implemented. | |
Language Code | |
-------- ---- | |
Afrikaans af | |
Albanian sq | |
Arabic ar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import statsmodels.api as sm | |
from statsmodels.formula.api import ols | |
# load some data | |
dta = sm.datasets.longley.load_pandas() | |
# make a standardized RHS formula | |
stand = "standardize(%s)" | |
std_rhs = ' + '.join([stand]*len(dta.exog_name)) % tuple(dta.exog_name) | |
print std_rhs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy import special, stats | |
from statsmodels.base.model import GenericLikelihoodModel | |
def vuong_test(p1, p2): | |
r""" | |
Vuong-test for non-nested models. | |
Parameters | |
---------- |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This took me a while to figure out so posting for posterity. | |
plt.interactive(False) is important, if you want the grid to only show up | |
when `display`ed. Since `sns.FacetGrid` can take a few seconds depending | |
on the size of your data, this displays a spinner in the notebook cell | |
until the new graph is ready to render. | |
""" | |
import matplotlib.pyplot as plt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
#As a path collection | |
from matplotlib.collections import LineCollection | |
fig, ax = plt.subplots() | |
r = np.arange(0, .075, 0.00001) | |
nverts = len(r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import glob | |
import os | |
import shutil | |
import re | |
from collections import namedtuple | |
import subprocess | |
from subprocess import PIPE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set more off | |
capture program drop ZIP_FE_model | |
program define ZIP_FE_model | |
version 9.1 | |
args todo b lnf | |
tempvar theta1 lambda last nonz w sln0 sln r0 r nb0 nb1 nb00 nb2 L2 | |
local by "$MY_panel" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import calendar | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.ticker import FixedLocator, FixedFormatter | |
import pandas as pd | |
import seaborn as sns | |
to_colors = lambda x : x/255. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from boto3 import client | |
client = client(service_name='ec2') | |
prices = client.describe_spot_price_history(InstanceTypes=["m3.medium"], | |
AvailabilityZone="us-east-1a") | |
df = pd.DataFrame(prices['SpotPriceHistory']) | |
df.set_index("Timestamp", inplace=True) | |
df["SpotPrice"] = df.SpotPrice.astype(float) |
NewerOlder