hrue / r-inla

This is the public repository for the r-inla project
GNU General Public License v2.0
88 stars 24 forks source link

Support for multi-response modelling #91

Closed stanleyrazor closed 7 months ago

stanleyrazor commented 7 months ago

Greetings, I have been trying to fit a multi response model using R-INLA package, with the following data:

dd = data.frame(
  x1 = runif(100),
  x2 = runif(100)
) |>
  mutate(
    y1 = 2 - x1 + rnorm(100),
    y2 = 2 - .4*x1 + 1*x2 + rnorm(100)
  )

formula <- cbind(y1, y2) ~ x1 + x2
result <- inla(formula, family="gaussian", data=dd)

Is this currently supported by INLA, as I seem to have gotten the formula wrongly.

Best.

hrue commented 7 months ago

This is not how it can be done.

can you post to @.*** instead ?

On Wed, 2024-03-13 at 10:06 -0700, Stanley sayianka wrote:

Greetings, I have been trying to fit a multi response model using R-INLA package, with the following data: dd = data.frame(   x1 = runif(100),   x2 = runif(100) ) |>   mutate(     y1 = 2 - x1 + rnorm(100),     y2 = 2 - .4x1 + 1x2 + rnorm(100)   )

formula <- cbind(y1, y2) ~ x1 + x2 result <- inla(formula, family="gaussian", data=dd) Is this currently supported by INLA, as I seem to have gotten the formula wrongly. Best. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Håvard Rue Professor of Statistics Chair of the Statistics Program CEMSE Division King Abdullah University of Science and Technology Thuwal 23955-6900 Kingdom of Saudi Arabia

@.*** Office: +966 (0)12 808 0640   Mobile: +966 (0)54 470 0421 Research group: bayescomp.kaust.edu.sa   R-INLA project: www.r-inla.org Zoom: kaust.zoom.us/my/haavard.rue

--

This message and its contents, including attachments are intended solely for the original recipient. If you are not the intended recipient or have received this message in error, please notify me immediately and delete this message from your computer system. Any unauthorized use or distribution is prohibited. Please consider the environment before printing this email.

hrue commented 7 months ago

n <- 100 dd = data.frame( x1 = runif(n), x2 = runif(n) ) |> mutate( y1 = 2 - x1 + rnorm(n), y2 = 2 - .4x1 + 1x2 + rnorm(n) )

N <- 2*n Y <- matrix(NA, N, 2)

Y[1:n, 1] <- dd$y1 Y[n + 1:n, 2] <- dd$y2

na <- rep(NA, n) x1.1 <- c(dd$x1, na) x2.1 <- c(dd$x2, na) x1.2 <- c(na, dd$x1) x2.2 <- c(na, dd$x2)

this will use the same intercept and two precisions for the

obsersations, one for each.

formula <- Y ~ x1.1 + x2.1 + x1.2 + x2.2 result <- inla(formula, family=rep("gaussian",2), data=list(Y = Y, x1.1 = x1.1, x1.2 = x1.2, x2.1 = x2.1, x2.2 = x2.2))

On Wed, 2024-03-13 at 20:28 +0300, Haavard Rue wrote:

This is not how it can be done.

can you post to @.*** instead ?

On Wed, 2024-03-13 at 10:06 -0700, Stanley sayianka wrote:

Greetings, I have been trying to fit a multi response model using R-INLA package, with the following data: dd = data.frame(   x1 = runif(100),   x2 = runif(100) ) |>   mutate(     y1 = 2 - x1 + rnorm(100),     y2 = 2 - .4x1 + 1x2 + rnorm(100)   )

formula <- cbind(y1, y2) ~ x1 + x2 result <- inla(formula, family="gaussian", data=dd) Is this currently supported by INLA, as I seem to have gotten the formula wrongly. Best. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

Haavard Rue @.***

stanleyrazor commented 7 months ago

This is not how it can be done. can you post to @.*** instead ?

Sorry, I have not understood what you meant here.

stanleyrazor commented 7 months ago

n <- 100 dd = data.frame( x1 = runif(n), x2 = runif(n) ) |> mutate( y1 = 2 - x1 + rnorm(n), y2 = 2 - .4x1 + 1x2 + rnorm(n) ) N <- 2*n Y <- matrix(NA, N, 2) Y[1:n, 1] <- dd$y1 Y[n + 1:n, 2] <- dd$y2 na <- rep(NA, n) x1.1 <- c(dd$x1, na) x2.1 <- c(dd$x2, na) x1.2 <- c(na, dd$x1) x2.2 <- c(na, dd$x2) ## this will use the same intercept and two precisions for the ## obsersations, one for each. formula <- Y ~ x1.1 + x2.1 + x1.2 + x2.2 result <- inla(formula, family=rep("gaussian",2), data=list(Y = Y, x1.1 = x1.1, x1.2 = x1.2, x2.1 = x2.1, x2.2 = x2.2))

Thank you for the quick response. This works. Best,