使用INLA与光栅在R



我以前使用过INLA与SpatialPolygonsDataFrame之前,但我从来没有使用过光栅。我已经在网上搜索了好几个小时,阅读了小短文和我能找到的所有东西,但仍然不知道如何将INLA与光栅一起使用。下面是我的数据的一个简单示例:

library("raster")
library("INLA")
lat = c(10, 10, 10, 10, 14, 14, 14, 14, 10, 10, 10, 10, 14, 14, 14, 14)
lon = c(20 ,24, 28, 32, 20, 24, 28, 32, 20, 24, 28, 32, 20, 24, 28, 32)
response = c(17.3, 17.4, 17.6, 17.9, 17.1, 17.0, 17.4, 17.5, 17.4, 17.4,
17.7, 17.8, 17.2, 17.1, 17.7, 17.9)
explan1 = c(31, 35, 33, 36, 32, 37, 36, 40, 32, 34, 33, 37, 35, 35, 39, 38)
explan2 = c(112, 116, 111, 114, 115, 117, 117, 112, 110, 114, 113, 117, 112,
113, 115, 116) 
data.df = data.frame(lat = lat, lon = lon, response = response, explan1 = 
explan1, explan2 = explan2)
myGrid = raster(ncol = 5, nrow = 5)

所以我把自己扔到你们所有人面前,以这种方式乞求怜悯和帮助。

要拟合数据,请使用您的数据。Df(和你的时空模型)。

要在栅格上预测/投影,使用inla.mesh.project。您可以投影结果$summary.linear。预测,结果summary.fitted美元。值,或结果$summary。随机的,取决于你的代码和你想要得到什么。

如果你想要样本而不是总结,使用inla.posterior。样品,并投影正确的部分(取决于您的模型)。

时空模型非常复杂,工作实例非常长。请参阅spde教程http://www.r-inla.org/examples/tutorials/spde-tutorial

最新更新