Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .RData
Binary file not shown.
292 changes: 292 additions & 0 deletions .Rhistory
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@
df = data.frame("x" = c(1), "y" =c(2))
df
linearmodel = lm(y ~ x, data = df)
linearmodel
dunif(x, min = 0, max = 1, log = FALSE)
matrix(0, 1, 1000)
matrix(0, 1, 1000)
dunif(x, min = 0, max = 1, log = FALSE)
1000)
dunif(x, min = 0, max = 1, log = FALSE)
dunif(x, min = 0, max = 1, log = FALSE)
x=matrix(0, 1, 1000)
dunif(x, min = 0, max = 1, log = FALSE)
x=dunif(x, min = 0, max = 1, log = FALSE)
x
x=punif(q, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE)
x=punif(x, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE)
x
u <- runif(1000)
u
u <- runif(x)
u
u <-runif(x, min = 0, max = 1)
u
clear
u <- runif(1000)
u
attributes(u)
summarize(u)
describe.u
describe(u)
x=matrix(0,1000)
x
describe(u)
describe.vector(u)
describe.matrix(u)
str(u)
typeof(u)
typeof(u)
u
typeof(u)
bidders1 <- u[1:500]
bidders1 = u[1:500]
u <- runif(x)
x=matrix(0,1000)
u <- runif(x)
bidders1 <- u[1:500]
bidders1
x=matrix(0,1000)
u <- runif(x)
bidders1 <- u[1:500]
dim(bidders1) <- c(125,4)
bidders1`
x=matrix(0,1000)
u <- runif(x)
bidders1 <- u[1:500]
dim(bidders1) <- c(125,4)
bidders1
dim(bids) <- c(125,4)
dim(bids1) <- c(125,4)
bidders <- runif(matrix(0,1000))
bids1 <- (3/4)*u[1:500]
dim(bids1) <- c(125,4)
bids1
bidders <- runif(matrix(0,1000))
bids1 <- (3/4)*u[1:500]
dim(bids1) <- c(125,4)
bids2 <- (4/5)*u[501:1000]
dim(bids2) <- c(100,5)
bids2
# library(TTR)
# djia = getYahooData("^DJI", start=20060420, end=20160420, freq="daily")
library(xts)
djiar = diff(log(djia$Close))[-1] # approximate returns
plot(djiar, main="DJIA Returns", type="n")
lines(djiar)
library(TTR)
djia = getYahooData("^DJI", start=20060420, end=20160420, freq="daily")
library(xts)
djiar = diff(log(djia$Close))[-1] # approximate returns
plot(djiar, main="DJIA Returns", type="n")
lines(djiar)
library(TTR)
djiar = getYahooData("^DJI", start=20060420, end=20160420, freq="daily")
library(xts)
djiar = diff(log(djia$Close))[-1] # approximate returns
plot(djiar, main="DJIA Returns", type="n")
lines(djiar)
install.packages("astsa")
library(astsa)
.First <- function(){library(astsa)}
1:5
seq(1, 10, by=2)
x=c(1:20); y=c(1:5); x*y
ls()
ls(pattern=2)
ls(pattern=bid)
ls(pattern="bid")
ls(pattern=.4020)
ls(pattern=.402)
ls()
ls(pattern=u)
ls(pattern="u")
help(read.table)
x = 1:3; y = 4:6
(u = c(x, y)) # an R vector
(u1 = cbind(x, y))
(u1 = cbind(t(x), t(y))
(u1 = cbind(t(x), t(y))
library(TTR)
djiar = getYahooData("^DJI", start=20060420, end=20160420, freq="daily")
library(xts)
djiar = diff(log(djia$Close))[-1] # approximate returns
plot(djiar, main="DJIA Returns", type="n")
lines(djiar)
library(tidyverse)
library(readr)
library(cubature)
setwd("C:/Users/Joe/github/empirical-methods")
dt <- read.delim("ProblemSets/pset1/bids1.csv")
dt <- rbind(2.9679,dt) # first observation was read as a column name, so put it back as an observation
names(dt)<- "bids"
mean(dt$bids)
X <- dt$bids
I <- 1:300 # index vector
H <- seq(from=.01, to=.3, by=.001) # bandwidth vector
# you need full sample density estimate to do CV
epan <- density(dt$bids, kernel= "epanechnikov", bw = "SJ", adjust = 1)
# test on X[i]
y_j <- function(j) density(dt$bids, kernel= "epanechnikov", bw = "SJ", adjust = 1)
yhatj <- function(i,j) density(X[-i],from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw="SJ")$y
MSEi <- function(i) (y_j(j)- yhatj(i,j))^2
MSEhat <- sum(sapply(I, MSEi))
y_j <- function(j) density(dt$bids, kernel= "epanechnikov", bw = "SJ", adjust = 1)
yhatj <- function(i,j) density(X[-i],from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw="SJ")$y
MSEi <- function(i) (y_j(j)- yhatj(i,j))^2
MSEhat <- sum(sapply(I, MSEi))
J <- I # another index vector
MSEhat <- sum(mapply(I,J, FUN=MSEi))
y_j <- function(j) density(dt$bids, kernel= "epanechnikov", bw = "SJ", adjust = 1)
yhatj <- function(i,j) density(X[-i],from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw="SJ")$y
MSEi <- function(i,j) (y_j(j)- yhatj(i,j))^2
MSEhat <- sum(mapply(I,J, FUN=MSEi))
y_j <- function(j) density(dt$bids, kernel= "epanechnikov", bw = "SJ", adjust = 1)$y
yhatj <- function(i,j) density(X[-i],from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw="SJ")$y
MSEi <- function(i,j) (y_j(j)- yhatj(i,j))^2
MSEhat <- sum(mapply(I,J, FUN=MSEi))
MSEi(1)
MSEi(i=1,j=1)
y_j(1)
?density
y_j(0)
# test on X[i]
y_j <- function(j) density(dt$bids, n=1, kernel= "epanechnikov", bw = "SJ", adjust = 1)$y
yhatj <- function(i,j) density(X[-i],from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw="SJ")$y
MSEi <- function(i,j) (y_j(j)- yhatj(i,j))^2
MSEhat <- sum(mapply(I,J, FUN=MSEi))
y_j(1)
y_j(2)
y_j(0)
y_j(-1)
y_j <- function(j) density(dt$bids,from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw = "SJ", adjust = 1)$y
yhatj <- function(i,j) density(X[-i],from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw="SJ")$y
MSEi <- function(i,j) (y_j(j)- yhatj(i,j))^2
MSEhat <- sum(mapply(I,J, FUN=MSEi))
y_j(1)
y_j(10)
y_j(100)
epan <- density(dt$bids, kernel= "epanechnikov", bw = "SJ", adjust = 1)
epan(1)
epan(1)$y
y_j <- function(j) density(X,from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw = "SJ", adjust = 1)$y
yhatj <- function(i,j) density(X[-i],from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw="SJ")$y
MSEi_summand <- function(i,j) (y_j(j)- yhatj(i,j))^2
MSEi_summand(1)
MSEi_summand(i=1,j=1)
MSEi_summand(i=1,j=2)
MSEi_summand(i=1,j=3)
MSEi_summand(i=1,j=4)
MSEi_summand(i=1,j=5)
?Vectorize
MSEi <- sum(Vectorize(MSEi_summand))
MSEi <- sum(Vectorize(FUN=MSEi_summand))
MSEi <- Vectorize(FUN=MSEi_summand)
MSEi_vec <- Vectorize(FUN=MSEi_summand)
MSEi_vec(i,J)
?rep
i_vec <- rep(1, time=300)
MSEi_vec <- Vectorize(FUN=MSEi_summand)
MSEi_vec(i_vec,J)
y_j <- function(j) density(X,from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw = "SJ", adjust = 1)$y
yhatj <- function(i,j,h) density(X[-i],from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw=h)$y
MSEi_summand <- function(i,j,h) (y_j(j)- yhatj(i,j,h))^2
h_vec <- rep(.1, time=300)
i_vec <- rep(1, time=300)
MSEi_vec <- Vectorize(FUN=MSEi_summand)
MSEi <- sum(MSEi_vec)
MSEhat <- sum(mapply(I,J, FUN=MSEi))
y_j <- function(j) density(X,from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw = "SJ", adjust = 1)$y
yhatj <- function(i,j,h) density(X[-i],from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw=h)$y
MSEi_summand <- function(i,j,h) (y_j(j)- yhatj(i,j,h))^2
h_vec <- rep(.1, time=300)
i_vec <- rep(1, time=300)
MSEi_vec <- Vectorize(FUN=MSEi_summand)
MSEi <- sum(MSEi_vec)
epan <- density(dt$bids, kernel= "epanechnikov", bw = "SJ", adjust = 1)
# test on X[i]
y_j <- function(j) density(X,from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw = "SJ", adjust = 1)$y
yhatj <- function(i,j,h) density(X[-i],from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw=h)$y
MSEi_summand <- function(i,j,h) (y_j(j)- yhatj(i,j,h))^2
h_vec <- rep(.1, time=300)
i_vec <- rep(1, time=300)
MSEi_vec <- Vectorize(FUN=MSEi_summand)
MSEi_vec(i_vec,J,h_vec)
MSEi <- sum(MSEi_vec)
MSEi <- sum(MSEi_vec(i_vec,h_vec,J))
MSEi <- sum(MSEi_vec(i_vec,J,h_vec))
MSEi
h_vec <- rep(.2, time=300)
i_vec <- rep(1, time=300)
MSEi_vec <- Vectorize(FUN=MSEi_summand)
MSEi <- sum(MSEi_vec(i_vec,J,h_vec))
MSEi
h_vec <- rep(.01, time=300)
i_vec <- rep(1, time=300)
MSEi_vec <- Vectorize(FUN=MSEi_summand)
MSEi <- sum(MSEi_vec(i_vec,J,h_vec))
MSEi
h_vec <- rep(.5, time=300)
i_vec <- rep(1, time=300)
MSEi_vec <- Vectorize(FUN=MSEi_summand)
MSEi <- sum(MSEi_vec(i_vec,J,h_vec))
MSEi
MSEhat <- function(h){
h_vector <- rep.int(h, 300)
i_vector <- rep.int(i, 300)
return(sum(mapply(i_vector, J, h_vector, FUN=MSEi)))
}
MSEhat <- function(h){
h_vector <- rep.int(h, 300)
i_vector <- rep.int(i, 300)
return(MSEi(i_vector, J, h_vector, FUN=MSEi))
}
MSEhat(.1)
# you need full sample density estimate to do CV
epan <- density(dt$bids, kernel= "epanechnikov", bw = "SJ", adjust = 1)
# test on X[i]
y_j <- function(j) density(X,from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw = "SJ", adjust = 1)$y
yhatj <- function(i,j,h) density(X[-i],from=X[j],to=X[j],n=1, kernel= "epanechnikov", bw=h)$y
MSEi_summand <- function(i,j,h) (y_j(j)- yhatj(i,j,h))^2
MSEi_vec <- Vectorize(FUN=MSEi_summand)
MSEi <- function(i,h){
i_vec <- rep(1, time=300)
h_vec <- rep(.5, time=300)
MSEi_vec(i_vec, J, h_vec, FUN=MSEi_vec)
}
MSEi(1,1,)
MSEi(1,1)
MSEi_vec <- Vectorize(FUN=MSEi_summand)
MSEi <- function(i,h){
i_vec <- rep(1, time=300)
h_vec <- rep(.5, time=300)
return(MSEi_vec(i_vec, J, h_vec))
}
MSEi(1,1)
MSEhat_i <- function(I) {
h_vec <- rep(.5, time=300)
return(sapply(I,h_vec,FUN=MSEi))
}
MSEhat_i <- function(h) {
h_vec <- rep(.5, time=300)
return(sapply(I,h_vec,FUN=MSEi))
}
MSEhat_i(.1)
MSEhat_i(.1)
MSEhat_i(.1)
MSEi(1,.1)
MSEhat_i <- function(h) {
h_vec <- rep(h, time=300)
return(sapply(I,h_vec,FUN=MSEi))
}
MSEhat_i(.1)
MSEi <- function(i,h){
i_vec <- rep(i, time=300)
h_vec <- rep(h, time=300)
return(MSEi_vec(i_vec, J, h_vec))
}
MSEhat_i <- function(h) {
h_vec <- rep(h, time=300)
return(sapply(I,h_vec,FUN=MSEi))
}
MSEhat_i(.1)
34 changes: 34 additions & 0 deletions Part 2 - Model_Selection/model-selection.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
<<<<<<< HEAD
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6500 64-bit) (preloaded format=pdflatex 2018.2.6) 5 FEB 2020 21:55
entering extended mode
**./model-selection.tex
(model-selection.tex
LaTeX2e <2017-04-15>
Babel <3.15> and hyphenation patterns for 75 language(s) loaded.
(../slideHeader.tex

! LaTeX Error: File `beamer.cls' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: cls)

Enter file name:
! Emergency stop.
<read *>

l.3 \usefonttheme
[onlymath]{serif}
*** (cannot \read from terminal in nonstop modes)


Here is how much of TeX's memory you used:
18 strings out of 493312
443 string characters out of 3138906
53761 words of memory out of 3000000
3659 multiletter control sequences out of 15000+200000
3640 words of font info for 14 fonts, out of 3000000 for 9000
1141 hyphenation exceptions out of 8191
12i,0n,7p,125b,8s stack positions out of 5000i,500n,10000p,200000b,50000s
! ==> Fatal error occurred, no output PDF file produced!
=======
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex 2018.4.16) 4 FEB 2020 13:31
entering extended mode
restricted \write18 enabled.
Expand Down Expand Up @@ -1837,3 +1870,4 @@ PDF statistics:
188 named destinations out of 1000 (max. 500000)
280 words of extra memory for PDF output out of 10000 (max. 10000000)

>>>>>>> upstream/master
Expand Down
Loading