[R-sig-Geo] calculate CRPS on rasters

Lorenzo Alfieri alfios17 at hotmail.com
Thu Nov 29 10:15:24 CET 2012


Hi Robert,
I was hoping to use the overlay function too, but it seems it doesn't work in this case. See the result:

CRPS  <- overlay(obs, pred, fun=function(x,y) crps(x,y)$crps)

Error in function (x, fun, filename = "", recycle = TRUE, ...)  : 
  cannot use this formula, probably because it is not vectorized

Lorenzo



Date: Wed, 28 Nov 2012 11:25:36 -0800
Subject: Re: [R-sig-Geo] calculate CRPS on rasters
From: r.hijmans at gmail.com
To: alfios17 at hotmail.com
CC: etiennebr at gmail.com; r-sig-geo at r-project.org

Lorenzo,
Given that solution, I think you can also express this (in a memory-safe fashion) like this :
CRPS  <- overlay(obs, pred, fun=function(x,y) crps(x, y)$crps)

Robert

On Tue, Nov 27, 2012 at 3:11 AM, Lorenzo Alfieri <alfios17 at hotmail.com> wrote:




Etienne,

thank you for the tip

Now it runs trough, by using



CRPS <- raster(ncol=10, nrow=10)

CRPS[] <- crps(obs[],pred[])$crps



Lorenzo





Date: Mon, 26 Nov 2012 21:37:13 -0500

Subject: Re: [R-sig-Geo] calculate CRPS on rasters

From: etiennebr at gmail.com

To: alfios17 at hotmail.com

CC: r-sig-geo at r-project.org



Lorenzo,



I don't know about your specific function, but you can access matrix using the []'s. So maybe something like :

CRPS <- raster(ncol=10, nrow=10)

CRPS[] <- crps(obs[],pred[])





Etienne



2012/11/26 Lorenzo Alfieri <alfios17 at hotmail.com>



CRPS <- raster(ncol=10, nrow=10)



for (i in 1:length(obs)){



  CRPS[i] <- crps(obs[i],pred[i])$CRPS



        [[alternative HTML version deleted]]



_______________________________________________

R-sig-Geo mailing list

R-sig-Geo at r-project.org

https://stat.ethz.ch/mailman/listinfo/r-sig-geo


 		 	   		  


More information about the R-sig-Geo mailing list