-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle NAs more clearly for predictions (was: Two questions regarding time knot and interactions) #132
Comments
For time indexed discretely and with no need for interpolation, |
For the second question, the * and : notation for covariate "interactions" is not supported. In inlabru, the predictor expression is a regular R expression, so * is simply plain multiplication, and : is a sequence constructor. I've started thinking of a special component type that could take a formula and/or model matrix, so that the user can have control over fixed effect interactions.
Both of these will construct a kronecker precision model, just as for your |
Thanks again for the answers! Here a follow up question (or actually a few). I went with
I got interesting results and decided to run predictions. And this is my main question here and relates to
The above example gives the gradient plot for week 1, or time knot 1, as I wasn't sure what was being predicted, until I tried predicting week 11 and 52, in addition to week 1 through 10. For 1 through 10 I get gradient plots as seen in the tutorial, for week 11 and 52, interestingly enough R does run the Looking forward to your answer. Many thanks in advance! |
Looking at the |
Hi,
I have two questions related to the same models I have been working on, and mostly comes down to proper coding. I have not done any R-INLA or inlabru workshop, so the knowledge I have picked up so far is through the internet, available literature, and my supervisor.
My first question is about coding a spatio-temporal model with time knots. I use weeks as my scale for time. In INLA I would prepare a one-dimensional mesh:
k <- 10
tknots <- seq(min(week) + (0.5nweek)/k, max(week) - (0.5nweek)/k, length=k)
mesh.t <-inla.mesh.1d(tknots)
I expected this would be the same with inlabru, but I am not sure whether this step is needed or not.
When I use the above mesh.t as group_mapper:
form1 = resp ~ Intercept +
ship(fveskey, model = "iid", n = n_veskey) +
myspde(coordinates, group = week, group_mapper = bru_mapper(mesh.t, indexed=TRUE),
model = inla.spde2.matern(mesh1c), control.group = list(model="ar1"))
I get a different outcome when not using mesh.t, but using bru_mapper_index(10):
form1i = resp ~ Intercept +
ship(fveskey, model = "iid", n = n_veskey) +
myspde(coordinates, group = week, group_mapper = bru_mapper_index(10),
model = inla.spde2.matern(mesh1c), control.group = list(model="ar1"))
When I plot both myspde's I see in both cases the time knots, same intervals on same scale x-axis, but different mode and quantiles and summaries and dic and waic are different as well. The first model form has the better values. I am not sure if defining mesh.t is necessary or even correct with inlabru, and would like to understand what the difference is between using bru_mapper(mesh.t) with 10 time knots, and bru_mapper_index(10).
++
My other question is about how to define interactions in the form. e.g. using "*" or ":" with inlabru.
From what I've read this should work for inla() just like in glm() for example. However, I'm not sure how to define it for bru(), so far what I have tried doesn't work.
I have tried, but clearly does not work:
form3 = resp ~ Intercept(1) +
depth + temp + sal +
windspeed : windir(fwinddir, model = "rw1", cyclic =TRUE, n = n_winddir) +
ship(fveskey, model = "iid", n = n_veskey) +
year(cyear, model = "iid", n = ncyear) +
myspde(coordinates, group = week, group_mapper = bru_mapper(mesh.t, indexed=TRUE),
model = inla.spde2.matern(mesh1c), control.group = list(model="ar1"))
I came across this forum post: #101 and started experimenting. The model runs with it, but I am not at all sure whether it's doing the right thing, or not.
This form works:
form3 = resp ~ Intercept(1) +
depth + temp + sal +
wind(wind.int(windspeed:fwinddir), model = "rw1", cyclic =TRUE, n = n_winddir) +
ship(fveskey, model = "iid", n = n_veskey) +
year(cyear, model = "iid", n = ncyear) +
myspde(coordinates, group = week, group_mapper = bru_mapper(mesh.t, indexed=TRUE),
model = inla.spde2.matern(mesh1c), control.group = list(model="ar1"))
In the summary I see the effect of wind, but I'm not sure what happened nor whether this is the correct way to define an interaction.
I hope my questions are clear and someone can advise me. Many thanks in advance!
The text was updated successfully, but these errors were encountered: