function (file = "", n = NULL, text = NULL, prompt = "?", keep.source = getOption("keep.source"),
srcfile = NULL, encoding = "unknown")
res.flexible <- estimate.functional(iden.fct = quantiles,
model = logistic,
Y = GDP$first,X = GDP$gRGDPF1,
theta0 = c(0,0),instruments = c("lag(Y)","X"),
stateVariable = GDP$first)
summary(res)
plot(res.flexible)
plot(res.flexible, limits=c(-5,10))
GDP
res.flexible <- estimate.functional(iden.fct = quantiles,
model = logistic,
Y = GDP$first,X = GDP$gRGDPF1,
theta0 = c(0,0),instruments = c("lag(Y)","X"),
stateVariable = GDP$first)
summary(res.flexible)
plot(res.flexible, limits=c(-5,10))
mean(GDP$first)
mean(GDP$gRGDPF1)
summary(res.flexible)
res.flexible$vcov
res.flexible$gmm$vcov
GDP <- GDP[-c(1,2):,]
GDP <- GDP[-c(1,2),]
res.flexible <- estimate.functional(iden.fct = quantiles,
model = logistic,
Y = GDP$first,X = GDP$gRGDPF1,
theta0 = c(0,0),instruments = c("lag(Y)","X"),
stateVariable = GDP$first)
summary(res.flexible)
plot(res.flexible, limits=c(-5,10))
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/R/estimate_functional.R', echo=TRUE)
res.flexible <- estimate.functional(iden.fct = quantiles,
model = logistic,
Y = GDP$first,X = GDP$gRGDPF1,
theta0 = c(0,0),instruments = c("lag(Y)","X"),
stateVariable = GDP$first)
gmm::gmm(g, x=matrix_data,t0=theta0,optfct=optfct,...)
optfct
matrix_data
res.flexible <- estimate.functional(iden.fct = quantiles,
model = logistic,
Y = GDP$first,X = GDP$gRGDPF1,
theta0 = c(0,0),instruments = c("lag(Y)","X"),
stateVariable = GDP$gRGDPF1)
summary(res.flexible)
plot(res.flexible, limits=c(-5,10))
summary(res.flexible)
plot(res.flexible, limits=c(-5,10))
library(lubridate)
library(xlsx)
# load observations
#Y<- read.csv("./data-raw/observations.csv", sep=";", dec=",", header=TRUE)
Y <- read.xlsx2("./data-raw/routput_first_second_third_all.xlsx",
sheetIndex = 2,startRow = 5)
#convert to numeric
Y[,-1] <- t(apply(Y[,-1], 1,function(x) as.numeric(as.character(x))))
# read forecasts
#X<- read.csv("./data-raw/forecasts.csv", sep=";", dec=",", header=TRUE)
X <- read.xlsx2("./data-raw/GBweb_Row_Format.xls", 2)[,c("DATE","gRGDPF1", "GBdate")]
X$gRGDPF1 <- as.numeric(as.character(X$gRGDPF1))
# format date
X$date <- as.Date(as.character(X$GBdate),"%Y%m%d")
####### Choose forecast closest to middle of the respective quarter
year(X$date)<-2000
X$comparison <-as.Date("02152000","%m%d%Y")
X$comparison[(month(X$date)>3)] <- as.Date("05152000","%m%d%Y")
X$comparison[(month(X$date)>6)] <- as.Date("08152000","%m%d%Y")
X$comparison[(month(X$date)>9)] <- as.Date("11152000","%m%d%Y")
X$diff<-abs(X$comparison-X$date)
X<-transform(X,
date.rank = ave(diff, DATE,
FUN = function(x) rank(x, ties.method = "first")))
#drop other forecasts
X.new <- X[X$date.rank==1,]
####### merge observations and forecasts
Y$Date <-gsub(":Q",".",Y$Date)
X.new$t <- 0
X.new$t[1:(dim(X.new)[1]-1)] <- X.new$DATE[-1]
Y<-merge(X.new,Y,by = 'DATE',by.y = 'Date')
# drop unnecessary variables
Y.full<-Y[,c('DATE','GBdate','gRGDPF1','First','Second','Most_Recent')]
###### Choose second or most recent vintage as robustness check
#Y<-Y.full[,c('Second','gRGDPF1')]
#Y<-Y.full[,c('recent','gRGDPF1')]
Y<-Y.full[,c('First','gRGDPF1')]
GDP <- Y
colnames(GDP)<-c("observation","forecast")
rownames(GDP)<-Y.full$DATE
GDP <- GDP[rownames(GDP)>=1969,]
GDP
library(lubridate)
library(xlsx)
# load observations
#Y<- read.csv("./data-raw/observations.csv", sep=";", dec=",", header=TRUE)
Y <- read.xlsx2("./data-raw/routput_first_second_third_all.xlsx",
sheetIndex = 2,startRow = 5)
#convert to numeric
Y[,-1] <- t(apply(Y[,-1], 1,function(x) as.numeric(as.character(x))))
# read forecasts
#X<- read.csv("./data-raw/forecasts.csv", sep=";", dec=",", header=TRUE)
X <- read.xlsx2("./data-raw/GBweb_Row_Format.xls", 2)[,c("DATE","gRGDPF1", "GBdate")]
X$gRGDPF1 <- as.numeric(as.character(X$gRGDPF1))
# format date
X$date <- as.Date(as.character(X$GBdate),"%Y%m%d")
####### Choose forecast closest to middle of the respective quarter
year(X$date)<-2000
X$comparison <-as.Date("02152000","%m%d%Y")
X$comparison[(month(X$date)>3)] <- as.Date("05152000","%m%d%Y")
X$comparison[(month(X$date)>6)] <- as.Date("08152000","%m%d%Y")
X$comparison[(month(X$date)>9)] <- as.Date("11152000","%m%d%Y")
X$diff<-abs(X$comparison-X$date)
X<-transform(X,
date.rank = ave(diff, DATE,
FUN = function(x) rank(x, ties.method = "first")))
#drop other forecasts
X.new <- X[X$date.rank==1,]
####### merge observations and forecasts
Y$Date <-gsub(":Q",".",Y$Date)
X.new$t <- 0
X.new$t[1:(dim(X.new)[1]-1)] <- X.new$DATE[-1]
head(X.new)
head(Y)
X <- read.xlsx2("./data-raw/GBweb_Row_Format.xls", 2)[,c("DATE","gRGDPF1", "GBdate")]
head(X)
X$date <- as.Date(as.character(X$GBdate),"%Y%m%d")
X$date
X$date+months(3)
quarter(X$date+months(3))
quarter(X$date+days(90))
X$date.target <- X$date+days(90)
paste0(years(X$date.target),".",quarter(X$date.target))
years(X$date.target)
paste0(year(X$date.target),".",quarter(X$date.target))
Y
head(Y)
Y$Date
library(lubridate)
library(xlsx)
# load observations
#Y<- read.csv("./data-raw/observations.csv", sep=";", dec=",", header=TRUE)
Y <- read.xlsx2("./data-raw/routput_first_second_third_all.xlsx",
sheetIndex = 2,startRow = 5)
#convert to numeric
Y[,-1] <- t(apply(Y[,-1], 1,function(x) as.numeric(as.character(x))))
# read forecasts
#X<- read.csv("./data-raw/forecasts.csv", sep=";", dec=",", header=TRUE)
X <- read.xlsx2("./data-raw/GBweb_Row_Format.xls", 2)[,c("DATE","gRGDPF1", "GBdate")]
X$gRGDPF1 <- as.numeric(as.character(X$gRGDPF1))
# format date
X$date <- as.Date(as.character(X$GBdate),"%Y%m%d")
X$date.target <- X$date+days(90)
X$date.target <- paste0(year(X$date.target),".",quarter(X$date.target))
####### Choose forecast closest to middle of the respective quarter
year(X$date)<-2000
X$comparison <-as.Date("02152000","%m%d%Y")
X$comparison[(month(X$date)>3)] <- as.Date("05152000","%m%d%Y")
X$comparison[(month(X$date)>6)] <- as.Date("08152000","%m%d%Y")
X$comparison[(month(X$date)>9)] <- as.Date("11152000","%m%d%Y")
X$diff<-abs(X$comparison-X$date)
X<-transform(X,
date.rank = ave(diff, DATE,
FUN = function(x) rank(x, ties.method = "first")))
#drop other forecasts
X.new <- X[X$date.rank==1,]
####### merge observations and forecasts
Y$Date <-gsub(":Q",".",Y$Date)
X.new$t <- 0
X.new$t[1:(dim(X.new)[1]-1)] <- X.new$DATE[-1]
merge(X.new,Y,by = 'DATE',by.y = 'Date')
merge(X.new,Y,by = 'date.target',by.y = 'Date')
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
summary(res.flexible)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/R/estimate_functional.R', echo=TRUE)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
summary(res)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
linearHypothesis(res$gmm,"Theta[2]=0")
summary(res.flexible)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
linearHypothesis(res$gmm,"Theta[2]=0")
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
plot(res.flexible,limits=c(-5,10))
res.flexible$gmm$vcov
linearHypothesis(res$gmm,"Theta[2]=0")
linearHypothesis(res.flexible$gmm,"Theta[2]=0")
GDP
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
plot(res,limits=c(-5,10))
summary(res)
linearHypothesis(res$gmm,"Theta[2]=0")
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
plot(res,limits=c(-5,10))+  scale_x_continuous("predicted growth rate", limits = c(-5,10))+
theme_classic(20)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
library(ggplot2)
plot(res,limits=c(-5,10))+  xlab("predicted growth rate")+
theme_classic(20)
summary(res)
ggsave('./data-raw/greenbook_confidence.pdf', height = 4, width=6)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/R/plot.R', echo=TRUE)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
GDP
dim(GDP)
ggsave('./data-raw/greenbook_confidence.pdf', height = 4, width=6)
summary(res)
linearHypothesis(res$gmm,"Theta[2]=0")
summary(res)
res$gmm$vcov
res <- estimate.functional(iden.fct = quantiles,
model = logistic,
Y = GDP$observation,X = GDP$forecast,
theta0 = c(0,0),
stateVariable = GDP$observation[-length(GDP$observation)])
res <- estimate.functional(iden.fct = quantiles,
model = logistic,
Y = GDP$observation,X = GDP$forecast,
theta0 = c(0,0),
stateVariable = c(0,GDP$observation[-length(GDP$observation)]))
library(ggplot2)
plot(res,limits=c(-5,10))+  xlab("predicted growth rate")+
theme_classic(20)
summary(res)
linearHypothesis(res$gmm,"Theta[2]=0")
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
devtools::document()
library(PointFore)
summary(res$gmm)
ls(summary(res$gmm))
summary(res$gmm)$stest
summary(res$gmm)$stest[2]
summary(res$gmm)$stest[1]
summary(res$gmm)$stest[2]
summary(res$gmm)$stest[2]$2
summary(res$gmm)$stest[2][2]
summary(res$gmm)$stest[2][1]
a <- summary(res$gmm)$stest[2]
a$test
a$test[2]
a <- summary(res$gmm)$stest$test[2]
a
res$gmm$coefficients
res$gmm$coefficients[2]
res$gmm$coefficients[1]
library(PointFore)
devtools::document
devtools::document()
library(PointFore)
res <- estimate.functional(Y=GDP$observation,X=GDP$forecast,
model=logistic,theta0=c(0,0),
stateVariable = lag(GDP$observation))
plot(res)
estimate.functional(Y=GDP$observation,X=GDP$forecast)
estimate.functional(Y=GDP$observation,X=GDP$forecast,
instruments=c("X","lag(Y)"))
estimate.functional(Y=GDP$observation,X=GDP$forecast,
other_data = data.frame(Z=GDP$forecast),
instruments=c("Z","lag(Y)"))
estimate.functional(Y=GDP$observation,X=GDP$forecast,
model=logistic,theta0=c(0,0),stateVariable = GDP$forecast)
devtools::document()
library(PointFore)
library(PointFore)
?plot.pointfore
devtools::document()
library(PointFore)
res <- estimate.functional(Y=GDP$observation,X=GDP$forecast,
model=logistic,
theta0=c(0,0),
stateVariable = GDP$forecast,
pdf=FALSE)
res <- estimate.functional(Y=GDP$observation,X=GDP$forecast,
model=logistic,
theta0=c(0,0),
stateVariable = GDP$forecast)
summary(res)
plot(res, pdf=FALSE)
plot(res, pdf=FALSE,conf.levels = c(0.6,0.9))
library(scales)
plot.dat <- data.frame(X=Y.full[,"gRGDPF1"],Y=Y.full[,"first"], Date = as.Date(as.character(Y.full$GBdate),"%Y%m%d"))
plot.dat <- data.frame(X=Y.full[,"gRGDPF1"],Y=Y.full[,"First"], Date = as.Date(as.character(Y.full$GBdate),"%Y%m%d"))
p <- ggplot(plot.dat)+
geom_line(aes(x=Date,y=Y))+
geom_point(aes(x=Date,y=X), color = 'red', size = 2, shape=4)+
ylab('GDP growth')+
xlab('')+
theme_classic(15)+scale_x_date(labels = date_format("%b %Y"))
p
ggsave(p, filename = './data-raw/gdp.pdf', width = 10, height = 3)
library(PointFore)
library(PointFore)
?PointFore
devtools::document()
library(PointFore)
mylist <- list("a","b")
mylist
mylist <- list(a="a",b="b")
mylist$a
name <- "a"
get(name)
name
aa <- "a"
get(aa)
get(mylist(aa))
mylist[[aa]]
mylist <- list(a=1,b=2)
var <- "a"
mylist[[var]]
mylist[var]
?lapply
?tapply
?apply
document()
devtools::use_build_ignore(".README-example-1.png")
devtools::use_build_ignore(".README-example with state-dependence-1.png")
devtools::document()
devtools::build()
devtools::release()
install.packages(c("broom", "devtools", "ggplot2", "git2r", "haven", "MASS", "mgcv", "survival", "tinytex"))
install.packages(c("broom", "devtools", "ggplot2", "git2r", "haven", "MASS", "mgcv", "survival", "tinytex"))
devtools::release()
install.packages("devtools")
install.packages("ggplot2")
devtools::release()
install.packages("roxygen2")
devtools::release()
2
devtools::release()
install.packages("gmm")
install.packages("ggplot2")
devtools::release()
install.packages("car")
install.packages("boot")
install.packages("boot")
install.packages("MASS")
install.packages("stats")
install.packages("stats")
install.packages("stats")
devtools::release()
install.packages("knitr")
devtools::release()
install.packages("rmarkdown")
devtools::release()
devtools::release()
build_win()
devtools::build_win()
library(PointFore)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
install.packages("lubridate")
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
install.packages("xlsx")
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
library(PointFore)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/data-raw/GDP application2.R', echo=TRUE)
res <- estimate.functional(iden.fct = quantiles,
Y = GDP$observation,X = GDP$forecast)
summary(res)
source('C:/Users/Patrick Schmidt/Dropbox/R packages/PointFore/R/estimate_functional.R', echo=TRUE)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,instruments = c("X","X")
theta0 = 0.5)
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,instruments = c("X","X"),
theta0 = 0.5)
set.seed(1)
Y.mean <- rnorm(200,0,1)
Y <- rnorm(200,Y.mean,1)
X <- Y.mean
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,instruments = c("X","X"),
theta0 = 0.5)
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,instruments = c("X","X"),
theta0 = 0.5)
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,
theta0 = 0.5)
summary(res.const)
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,
theta0 = 0.5)
summary(res.const)
source('C:/Users/Patrick Schmidt/Dropbox/R packages/PointFore/R/estimate_functional.R', echo=TRUE)
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,
theta0 = 0.5)
library(PointFore)
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,instruments = c("X","X"),
theta0 = 0.5)
source('C:/Users/Patrick Schmidt/Dropbox/R packages/PointFore/R/estimate_functional.R', echo=TRUE)
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,
theta0 = 0.5)
source('C:/Users/Patrick Schmidt/Dropbox/R packages/PointFore/R/estimate_functional.R', echo=TRUE)
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,
theta0 = 0.5)
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,instruments = c("X","X")
theta0 = 0.5)
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,instruments = c("X","X"),
theta0 = 0.5)
source('C:/Users/Patrick Schmidt/Dropbox/R packages/PointFore/R/estimate_functional.R', echo=TRUE)
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,instruments = c("X","X"),
theta0 = 0.5)
res.const <- estimate.functional(
iden.fct = expectiles,
model = constant,
Y = Y,
X = X,
theta0 = 0.5)
library(PointFore)
qnorm(0.1)
pnorm(0.1)
pnorm(0)
source('C:/Users/s4667477.ITS/Dropbox/R packages/PointFore/R/estimate_functional.R', echo=TRUE)
res <- estimate.functional(Y=GDP[,1],X=GDP[,2])
library(PointFore)
probit <- function(stateVariable, theta)
{
if(length(theta)!=2){stop("Wrong dimension of parameter theta for probit model")}
return(pnorm(stateVariable*theta[2]+theta[1]))
}
res <- estimate.functional(Y=GDP[,1],X=GDP[,2])
summary(res)
res <- estimate.functional(Y=GDP$observation,X=GDP$forecast,
model=logistic,
theta0=c(0,0),
stateVariable = GDP$forecast)
summary(res)
res <- estimate.functional(Y=GDP$observation,X=GDP$forecast,
model=probit,
theta0=c(0,0),
stateVariable = GDP$forecast)
summary(res)
res <- estimate.functional(Y=GDP$observation,X=GDP$forecast,
model=probit,
theta0=c(0,0),
stateVariable = GDP$forecast)
summary(res)
plot(res,
pdf=FALSE,
conf.levels = c(0.6,0.9))
library(PointFore)
?probit
?logistic
devtools::document()
?pnorm
devtools::document()
devtools::document()
library(PointFore)
library(PointFore)
?probit
library(PointFore)
?probit
devtools::document()
