PageRenderTime 16ms CodeModel.GetById 9ms app.highlight 3ms RepoModel.GetById 2ms app.codeStats 0ms

/working/auteur/R/calibrate.jumpsize.R

http://github.com/eastman/auteur
R | 13 lines | 9 code | 2 blank | 2 comment | 4 complexity | aedd07fd0b4331e238e7f98b0bb9ecef MD5 | raw file
 1#rjmcmc utility for initiating a proposal width for Markov sampling
 2#author: JM EASTMAN 2010
 3
 4calibrate.jumpsize <-
 5function(phy, dat, nsteps=100, jumpsizes=NULL) {
 6	if(!withinrange(nsteps, 100, 1000)) {
 7		if(nsteps>1000) nsteps=1000 else nsteps=100
 8	}
 9	if(is.null(jumpsizes)) jumpsizes=2^(-2:3)
10	acceptance.rates=sapply(jumpsizes, function(x) rjmcmc.bm(phy=phy, dat=dat, ngen=nsteps, jumpsize=x, summary=FALSE, fileBase="jumpsize", internal.only=FALSE)$acceptance.rate)
11	return(sum(jumpsizes*(acceptance.rates/sum(acceptance.rates))))
12}
13