标签: r-inla

从后验预测分布中采样(stan vs inla)

我正在尝试在对象bayesplot上实现包中的函数INLA,并且有点不确定如何从后验预测分布中提取。我想我几乎已经拿到了,但是rstan 抽签比抽签更加多变INLA

在 中,使用小插图rstan中的简化示例我可以:bayesplot

library(bayesplot)
library(ggplot2)
library(rstanarm)
library(ggpubr)
library(tidyverse)


#rstan model set up
roaches$roach100 <- roaches$roach1 / 100 # pre-treatment number of roaches (in 100s)
fit_poisson <- stan_glm(y ~ roach100 + treatment + senior, offset = log(exposure2), family = poisson(link = "log"), data = roaches,  seed = 1111,  refresh = 0) 


#In order to use the PPC functions from the bayesplot package we need a vector y of outcome …
Run Code Online (Sandbox Code Playgroud)

r mixed-models rstan rstanarm r-inla

5
推荐指数
0
解决办法
931
查看次数

错误“dsparseModelMatrix”对象:未定义超类“xMatrix”

我正在使用 INLA 运行一个贝叶斯模型,该模型昨天还可以工作,今天就不再工作了(多么令人沮丧)。因此,我学习了之前检查过的教程,该教程也有效(https://becarioprecario.bitbucket.io/inla-gitbook/ch-spatial.html#spatial-models-using-stochastic-partial- Differential -equations)。但同样,由于同样的原因,它不再起作用:

\n
options(repos = c(getOption("repos"),\n                  INLA="https://inla.r-inla-download.org/R/stable"))\ninstall.packages("INLA", dep = TRUE)\n\nlibrary(sp)\nlibrary(gstat)\nlibrary(INLA)\ndata(meuse)\n\n\ncoordinates(meuse) <- ~x+y\nproj4string(meuse) <- CRS("+init=epsg:28992")\n\ndata(meuse.grid)\ncoordinates(meuse.grid) = ~x+y\nproj4string(meuse.grid) <- CRS("+init=epsg:28992")\ngridded(meuse.grid) = TRUE\n\nlibrary(maptools)\nmeuse.bdy <- unionSpatialPolygons(\n  as(meuse.grid, "SpatialPolygons"), rep (1, length(meuse.grid))\n)\n\npts <- meuse.bdy@polygons[[1]]@Polygons[[1]]@coords\nmesh <- inla.mesh.2d(loc.domain = pts, max.edge = c(150, 500),\n                     offset = c(100, 250) )\n\nmeuse.spde <- inla.spde2.matern(mesh = mesh, alpha = 2)\nA.meuse <- inla.spde.make.A(mesh = mesh, loc = coordinates(meuse))\ns.index <- inla.spde.make.index(name = "spatial.field",\n                                n.spde = meuse.spde$n.spde)\nmeuse.stack <- inla.stack(data  = list(zinc = meuse$zinc),\n                          A = list(A.meuse, 1),\n                          effects = list(c(s.index, …
Run Code Online (Sandbox Code Playgroud)

r r-inla

1
推荐指数
1
解决办法
459
查看次数

标签 统计

r ×2

r-inla ×2

mixed-models ×1

rstan ×1

rstanarm ×1