Skip to content

Commit

Permalink
work with non-named arguments in MLE, consistent ordering for plot le…
Browse files Browse the repository at this point in the history
…gends
  • Loading branch information
cboettig committed Dec 28, 2012
1 parent 3c8ccf3 commit 5da7c10
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/gp-replicate-fns.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ par_est_allee <- function(obs, f, p,
){
estf <- function(p){
mu <- f(obs$x,0,p)
-sum(dlnorm(obs$y, log(mu), p["s"]), log=TRUE)
-sum(dlnorm(obs$y, log(mu), p[4]), log=TRUE)
}
par = init
o <- optim(par, estf, method="L", lower=c(1e-3,1e-3,1e-3, 1e-3))
Expand Down Expand Up @@ -108,11 +108,13 @@ simulate_opt <- function(OPT, f, p, x_grid, h_grid, x0, z_g, profit){
sim_est <- lapply(1:100, function(i) ForwardSimulate(f, p, x_grid, h_grid, x0, OPT$est_D, z_g, profit=profit))
set.seed(1)
sim_alt <- lapply(1:100, function(i) ForwardSimulate(f, p, x_grid, h_grid, x0, OPT$alt_D, z_g, profit=profit))

dat <- list(GP = sim_gp, Parametric = sim_est, True = sim_true, Structural = sim_alt)
dat <- melt(dat, id=names(dat[[1]][[1]]))
dt <- data.table(dat)
setnames(dt, c("L1", "L2"), c("method", "reps"))
dt
setkey(dt, method) # chance the ordering
dt[c("GP", "Parametric", "True", "Structural")]
}


Expand Down

0 comments on commit 5da7c10

Please sign in to comment.