Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using krigeST with separable spatio-temporal variogram when computing full covariance matrix #100

Open
maierhofert opened this issue Jan 25, 2022 · 0 comments

Comments

@maierhofert
Copy link

maierhofert commented Jan 25, 2022

I am getting an error message when running krigeST with a separable spatio-temporal variogram when computing the full covariance matrix.
Here is some reproducible code showing the error that I adapted from the krigeST example:

library(sp)
library(spacetime)
sumMetricVgm <- vgmST("separable",
                      space = vgm( 4.4, "Lin", 196.6,  3),
                      time  = vgm( 2.2, "Lin",   1.1,  2),
                      # joint = vgm(34.6, "Exp", 136.6, 12),
                      sill = 1)

data(air)
suppressWarnings(proj4string(stations) <- CRS(proj4string(stations)))
rural = STFDF(stations, dates, data.frame(PM10 = as.vector(air)))

rr <- rural[,"2005-06-01/2005-06-03"]
rr <- as(rr,"STSDF")

x1 <- seq(from=6,to=15,by=1)
x2 <- seq(from=48,to=55,by=1)

DE_gridded <- SpatialPoints(cbind(rep(x1,length(x2)), rep(x2,each=length(x1))), 
                            proj4string=CRS(proj4string(rr@sp)))
gridded(DE_gridded) <- TRUE
DE_pred <- STF(sp=as(DE_gridded,"SpatialPoints"), time=rr@time)
DE_kriged <- krigeST(PM10~1, data=rr, newdata=DE_pred,
                     modelList=sumMetricVgm, 
                     computeVar = TRUE,
                     fullCovariance = TRUE)
gridded(DE_kriged@sp) <- TRUE
stplot(DE_kriged)

I chased down the problem, krigeST calls krigeST.df, which calls covfn.ST, which calls covSeparable, which needs to called with argument separate = FALSE. This argument is missing and set to false with the following lines of code

if (missing(separate)) 
        separate <- inherits(x, "STF") & inherits(y, "STF") & 
            length(x) > 1 & length(y) > 1

as the argument x (and y) is of class "STSDF".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant