R/simulate.selectedmodgof.R

Defines functions simulate.selectedmodgof

Documented in simulate.selectedmodgof

simulate.selectedmodgof<- function(object, nsim=99, seed=1,dimyx=c(128,128),...){

	x<-object # hay que usar "object" as argument in order to register as a S3 simulate method

        result<-list()
	simu.model <- x$best.model
	cual <- class(simu.model)
	
	 bw <- x$best.sigma
	 
	 # envueltas para un HPC 
	 if("ecespa.minconfit"%in%cual & !is.na(bw) ){	   
	   lambda <- density.ppp(x$pp, sigma=bw, dimyx=dimyx)
	   simu.model$lambda <- lambda
	   set.seed(seed)
	    for( i  in 1:nsim){
	           
	           progressreport(i,nsim)
	   	   result[[i]] <- rIPCP(simu.model)
	   }
	}
	
	 # envueltas para un PC
        if("ecespa.minconfit"%in%cual & is.na(bw) ){
	  lambda <- predict(ppm(x$pp), type = "trend")
	  simu.model$lambda <- lambda
	   set.seed(seed)
	 for( i  in 1:nsim){
	          
	           progressreport(i,nsim)
	   	   result[[i]] <- rIPCP(simu.model)
	   }
	}
	
	 # envueltas para un HPP
        if("im"%in%cual  & !is.na(bw) ){
	 lambda <- density.ppp(x$pp, sigma=bw, dimyx=dimyx)
	 set.seed(seed)
  	 for( i  in 1:nsim){
	           
	           progressreport(i,nsim)
  	           result[[i]] <- rpoispp(lambda)
	   }
	}
	
	# envueltas para un P
	if("im"%in%cual & is.na(bw)){
	   lambda <- intensity(x$pp)
	   ventana<- x$pp$window
	     set.seed(seed)
	   for( i  in 1:nsim){
	         
	           progressreport(i,nsim)
	           result[[i]] <- rpoispp(lambda, win=ventana)
	   }
	}
	
	return(result)
}

Try the selectspm package in your browser

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

selectspm documentation built on Jan. 5, 2023, 5:10 p.m.