R/dsmError.R

Defines functions dsmError

Documented in dsmError

dsmError = function(fit){
	gamma.fun = fit$gamma.fun
	est.boundary = function(theta){
		theta.seq = fit$output$theta
		post.est = fit$output$estimate
		s=sort(c(theta.seq,2*pi,theta))
		index = which(s==theta)[1]
		if(theta==0 || theta==2*pi){ 
			value = post.est[1]
		} else {
			a = theta.seq[index-1]
			b = ifelse(index<201,theta.seq[index],2*pi)
			va = post.est[index-1]
			vb = ifelse(index<201,post.est[index],post.est[1])
		}
		return(((theta-a)/(b-a))*vb+(1-((theta-a)/(b-a)))*va)
	}
	app.est.boundary = function(u){
		u = matrix(u,length(u),1)
		apply(u,1,est.boundary)
	}
	size = length(fit$obs$r.obs)
	intensity = fit$obs$intensity
	gamma.fun.radii = gamma.fun(fit$obs$theta.obs)
	ground.truth = ifelse(fit$obs$r.obs<gamma.fun.radii,1,0)
	predicted = ifelse(fit$obs$r.obs<app.est.boundary(fit$obs$theta.obs),1,0)
	calc_dsm = max(1-measureMRI(intensity, actual = matrix(cbind(ground.truth,1-ground.truth), size,2), pre = matrix(cbind(predicted,1-predicted),size,2))$DSM)
	return(calc_dsm)
}

Try the BayesBD package in your browser

Any scripts or data that you put into this service are public.

BayesBD documentation built on May 1, 2019, 10:17 p.m.