You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
library(INLA)
n <- 10
locations <- data.frame(x = runif(n), y = runif(n))
values <- rnorm(n)
w <- matrix(0, n, n)
for (i in 1:n) {
for (j in 1:n) {
dist <- sqrt((locations$x[i] - locations$x[j])^2 + (locations$y[i] - locations$y[j])^2)
if (dist < 0.2) {
w[i, j] <- 1
}
}
}
formula <- values ~1+f(1,model = "bym",graph = w)
undebug(INLA:::inla.interpret.formula)
result <- inla(formula, data = locations, family = "gaussian")
print(result)
is my model have wrong?think you!
The text was updated successfully, but these errors were encountered:
Your component specification is wrong. You likely need this:
library(INLA)
n <- 10
locations <- data.frame(index = seq_len(n), x = runif(n), y = runif(n))
values <- rnorm(n)
w <- matrix(0, n, n)
for (i in 1:n) {
for (j in 1:n) {
dist <- sqrt((locations$x[i] - locations$x[j])^2 + (locations$y[i] - locations$y[j])^2)
if (dist < 0.2) {
w[i, j] <- 1
}
}
}
formula <- values ~1+f(index,model = "bym",graph = w)
result <- inla(formula, data = locations, family = "gaussian")
print(result)
@finnlindgren ,it work,thank you.but i find other problem,my data does't fit gaussian,so i chose poisson,
library(INLA)
set.seed(123)
n <- 100
lambda <- 3
y <- rpois(n, lambda)
data <- data.frame(y = y)
formula <- y ~ 1
result <- inla(formula, data = data, family = "poisson",
control.family = list(hyper = list(prec = list(prior = "gamma", param = c(1, 0.1)))))
i meet those error,the ,
control.family = list(hyper = list(prec = list(prior = "gamma", param = c(1, 0.1))))is shoud be deleted?thank you.i just want set a hyper
Error in inla.core.safe(formula = formula, family = family, contrasts = contrasts, :
Model poisson [ likelihood ], has none hyperparameters, but 'hyper' is list(prec = list(prior = "gamma", param = c(0.5, 0.1)))
library(INLA)
n <- 10
locations <- data.frame(x = runif(n), y = runif(n))
values <- rnorm(n)
w <- matrix(0, n, n)
for (i in 1:n) {
for (j in 1:n) {
dist <- sqrt((locations$x[i] - locations$x[j])^2 + (locations$y[i] - locations$y[j])^2)
if (dist < 0.2) {
w[i, j] <- 1
}
}
}
formula <- values ~1+f(1,model = "bym",graph = w)
undebug(INLA:::inla.interpret.formula)
result <- inla(formula, data = locations, family = "gaussian")
print(result)
is my model have wrong?think you!
The text was updated successfully, but these errors were encountered: