source("Zhang_simfuns.R") library(R2admb) setup_admb() compile_admb("analyzer_df",re=TRUE) compile_admb("analyzer",re=TRUE) ################## tauvec <- c(0.001,0.5,2) nMCMC <- 500 fn <- "Zhang_ADMBsim.RData" set.seed(1001) reslist <- list() reslist$res_admb_LX <- sfun2(admb.LX_fun,nMCMC=nMCMC,debug=TRUE) save("reslist",file=fn) reslist$res_admb_L <- sfun2(admb.L_fun,nMCMC=nMCMC,debug=TRUE) save("reslist",file=fn) reslist$res_admb_LX_is100 <- sfun2(admb.LX_fun,is=100,nMCMC=nMCMC) save("reslist",file=fn) ## if (FALSE) { ## ## testing ## for (i in 1:100) { ## cat(i,"\n") ## options(warn=2) ## set.seed(1000+i) ## admb.L_fun(n=50,tau=0.001,clean=FALSE) ## } ## load("current_run.RData") ## debug(fun) ## fun(n=nvec[i],tau=tauvec[j],clean=FALSE,verbose=TRUE) ## admb.L_fun0(n=50) ## admb.L_fun0 <- function(...,n,clean=TRUE,verbose=FALSE,is=0, ## tpl="analyzer_var0") { ## xargs <- "-mno 100000 -gbs 200000000 -cbs 100000000" ## d <- simfun(n=n,...) ## write_dat(tpl,list(n=n,x=d$x,Y=d$y)) ## if (is>0) { ## xargs <- paste(xargs,"-is",is) ## } ## run_admb(tpl,extra.args=xargs,verbose=verbose) ## g0 <- read_admb(tpl) ## if (clean) clean_admb(tpl) ## coef(summary(g0))[4:5,] ## } ## }