Understanding the summary.linear.predictor

21 views
Skip to first unread message

Brian

unread,
Jul 2, 2024, 7:52:18 AMJul 2
to R-inla discussion group
Hi,

After running the model
#' The inla() call
mod <- inla(
  formula,
  family = "binomial",
  Ntrials = numtrials,
  data = inla.stack.data(stk.full),
  control.family = control.family(link = 'logit'),
  control.predictor = list(
    compute = TRUE,
    link = 1,
    A = inla.stack.A(stk.full)
  ),
  control.compute = list(config = TRUE, return.marginals.predictor = TRUE),
  control.inla = list(tolerance = 1e-7),
  num.threads = 7,
  verbose = F
)  

I obtained a data frame with the mean, standard deviation, and quantiles of the linear predictors. However, I could not understand the dimensions of the data frame

```
> dim(data.frame(mod$summary.linear.predictor))
[1] 5774    7
```
My training data had 1446 rows with 9 independent variables

Finn Lindgren

unread,
Jul 2, 2024, 8:31:22 AMJul 2
to Brian, R-inla discussion group
Hi,
this is due to how the A-matrix and inla.stack construction work. See
the 2015 JSS paper by Lindgren and Rue:
https://www.jstatsoft.org/article/view/v063i19

In short, the predictor vector is a concatenation of \eta* and \eta,
where \eta is the basic linear predictor combination defined by the
data provided, which for inla.stack() generated data are the
individual component "effects", and \eta* = A \eta, which is the
predictor that gets associated with observations.
As shown in the ?inla.stack documentation example, you can use the
inla.stack.index() function as a convenience to find out what values
correspond to \eta* ("data") and to \eta ("effects").
For single stack constructions, the indices are easy to predict, but
for multi-stack models, the tag feature helps identify the precise
parts:

stk <- inla.stack(data=list(y=1:3),A=list(Matrix(1:18,3,6)),effects=list(data.frame(x=11:16)),tag="mytag")
inla.stack.index(stk,"mytag")

$data
[1] 1 2 3

$effects
[1] 4 5 6 7 8 9

Here, the data has three elements, A is a 3-by-6 matrix, and the
effect vector has 6 elements, the end result is that \eta* is in the
first three elements of summary.linear.predictor, and \eta are in the
following six elements.

Finn
> --
> You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/r-inla-discussion-group/7a50df90-7e4a-42a5-8384-d345e0188463n%40googlegroups.com.



--
Finn Lindgren
email: finn.l...@gmail.com

Brian

unread,
Jul 2, 2024, 8:50:21 AMJul 2
to R-inla discussion group
Thanks a lot, now I have understood
Reply all
Reply to author
Forward
0 new messages