Skip to content

Instantly share code, notes, and snippets.

View fditraglia's full-sized avatar

Francis DiTraglia fditraglia

View GitHub Profile
@fditraglia
fditraglia / Rtutorial3.R
Created September 23, 2013 15:52
R Tutorial #3 - Transcript and Suggested Solution Code
survey <- read.csv("http://www.ditraglia.com/econ103/old_survey.csv")
survey <- survey[,c("handedness", "height", "handspan")]
head(survey)
@fditraglia
fditraglia / Rtutorial2.R
Created September 9, 2013 19:53
R Tutorial #2 - Transcript and Suggested Solution Code
survey <- read.csv("http://www.ditraglia.com/econ103/old_survey.csv")
survey <- survey[,1:6]
@fditraglia
fditraglia / tryRtranscript.R
Created September 6, 2013 16:00
TryR Transcript
#1.1 Expressions
1 + 1
"Arr, matey!"
6*7
#1.2 Logical Values
3 < 4
2 + 2 == 5
#1.3 Variables
@fditraglia
fditraglia / Rtutorial1.R
Last active December 22, 2015 11:29
R Tutorial #1 - Transcript and Suggested Solution Code
x <- 5
x == 5
foo <- 3
bar <- 5
foo.bar <- foo + bar
foo.bar2 <- 2 * foo.bar
@fditraglia
fditraglia / inflation_survey_weight.R
Created May 17, 2013 21:31
Naive Weighted Inflation Forecast
library(Quandl)
p <- 100 * Quandl('FRED/GDPDEF', collapse = 'quarterly', start_date = '1960-01-01', end_date = '2012-01-01', type = 'ts', transformation = 'rdiff')
#Michigan Inflation Expectations aren't in Quandl yet
library(quantmod)
getSymbols("MICH",src="FRED")
#Median expected price change next 12 months, Survey of Consumers.
#Convert to ts object
MICH.start <- as.numeric(format.Date(start(MICH), '%Y'))
@fditraglia
fditraglia / BLPCsim.R
Last active December 15, 2019 21:08
Backward-looking Phillips Curve Simulation
#This script carries out a simulation study similar to that in Section 2 of ``Posterior Predictive Evidence on US Inflation...'' by Basturk et al (2012), exploring the effects of trend mis-specification on the estimate of the persistence of the inflation parameter.
#Library to implement Bai and Perron (2003)
library(strucchange)
set.seed(4513)
g <- 0.5 #Inflation persistence
N.sims <- 250 #Simulation repetitions