This file contains hidden or 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 method 1 | |
from linearmodels.panel import PanelOLS | |
import statsmodels.api as sm | |
exog = sm.add_constant(gf[['value','capital']]) | |
grunfeld_fe = PanelOLS(gf['invest'], exog, entity_effects=True, time_effects=False) | |
grunfeld_fe = grunfeld_fe.fit() | |
print(grunfeld_fe) | |
# Coding method 2 | |
grunfeld_fe = PanelOLS.from_formula("invest ~ value + capital + EntityEffects", data=gf) |
This file contains hidden or 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
sd |
This file contains hidden or 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 method 1 | |
from linearmodels.panel import PanelOLS | |
import statsmodels.api as sm | |
exog = sm.add_constant(gf[['value','capital']]) | |
grunfeld_fet = PanelOLS(gf['invest'], exog, entity_effects=True, time_effects=True) | |
grunfeld_fet = grunfeld_fe.fit() | |
print(grunfeld_fet) | |
# Coding method 2 | |
grunfeld_fet = PanelOLS.from_formula("invest ~ value + capital + EntityEffects + TimeEffects", data=gf) |
This file contains hidden or 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 | |
import numpy as np | |
import seaborn as sns | |
fatalities = pd.read_csv('/fatality.csv') | |
fatalities.head() |
This file contains hidden or 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
avg = fatalities.groupby('year')['mrall','beertax'].mean() | |
avg |
This file contains hidden or 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
sns.set(style="darkgrid") | |
g = sns.jointplot("beertax", "mrall", | |
data=avg, kind="reg", | |
color="m", height=6) |
This file contains hidden or 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 method 1 | |
from linearmodels.panel import PanelOLS | |
import statsmodels.api as sm | |
exog = sm.add_constant(fatalities[['beertax','mlda','jaild', | |
'comserd','vmiles','unrate','perinc']]) | |
fe = PanelOLS(fatalities['mrall'], exog, entity_effects=True, time_effects=True) | |
fe = fe.fit() | |
print(fe) | |
# Coding method 2 |
This file contains hidden or 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 method 1 | |
from linearmodels.panel import PanelOLS | |
import statsmodels.api as sm | |
exog = sm.add_constant(fatalities[['beertax','mlda','jaild','comserd', | |
'vmiles','unrate','perinc']]) | |
fe2 = PanelOLS(fatalities['mrall'], exog, entity_effects=True, time_effects=False) | |
fe2 = fe2.fit() | |
print(fe2) | |
# Coding method 2 |
This file contains hidden or 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 method 1 | |
from linearmodels.panel import PanelOLS | |
import statsmodels.api as sm | |
exog = sm.add_constant(fatalities[['beertax','mlda', | |
'jaild','comserd','vmiles','unrate','perinc']]) | |
fe2 = PanelOLS(fatalities['mrall'], exog, | |
entity_effects=True, time_effects=False) | |
fe2 = fe2.fit() | |
print(fe2) |
This file contains hidden or 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 method 1 | |
from linearmodels.panel import PanelOLS | |
import statsmodels.api as sm | |
exog = sm.add_constant(fatalities[['beertax','mlda', | |
'jaild','comserd','vmiles','unrate','perinc']]) | |
pooledOLS = PanelOLS(fatalities['mrall'], exog, | |
entity_effects=False, time_effects=False) | |
pooledOLS = pooledOLS.fit() | |
print(pooledOLS) |