SVC models - dueling BYM's?

316 views
Skip to first unread message

John Molitor

unread,
Apr 22, 2021, 8:31:22 PM4/22/21
to R-inla discussion group
Hello,

I'm fitting a Spatially Varying Coefficient (SVC) model, where intercepts and "slopes" (effect of exposure) vary via a region-level spatially smoothed distribution. It seems that the conventional wisdom is to use a BYM model on the intercepts, but the Besag (without the extra iid terms) on the slopes.

Why is this? Why not use BYM for both? I suspect it has to do with some aliasing/confounding issues. Could someone shed some light on this issue?

Thanks in advanced!

John

Helpdesk

unread,
Apr 24, 2021, 6:54:37 AM4/24/21
to John Molitor, R-inla discussion group

I see your point. You are free to do what you want, but adding an iid
term in the SVC model, seems a little unmotivated. Think about what
happen if you have more of those, then they all esssentially just add up
to one common iid noise term, which you have already in the 'bym' model
without covariates. so it seems like you have already this term covered
by the bym term without the covariate.

so in short, I would use 

f(idx, x, model='besag', constr=FALSE, scale.model=TRUE)

for each of the covariates. I would set the prior to be strict, as you
basically just want a 'correction' for the constant, like

hyper=list(prec=list(prior="pc.prec", param=c(0.1,0.01))

and then you can add structure on top of this.

Best
H
> --
> 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/37b7118b-cfcc-478d-abb0-44eb1497c0d7n%40googlegroups.com
> .

--
Håvard Rue
he...@r-inla.org

John Molitor

unread,
Apr 27, 2021, 12:36:59 PM4/27/21
to R-inla discussion group
Håvard,

Thank you very much for this.

Regarding "strict" priors: I am interested in examining spatially-varying effects of exposure. One issue is that of spatial confounding which some address by using restricted spatial regression. However, as you know, this requires the spatial field to be orthogonal to the covariate space and may not be desired.

Judging from some of your recent papers, it appears that you recommend informative priors to deal with spatial confounding instead of restricted spatial regression. Is this the case? In my situation, spatial smoothing on the intercepts is less important, and an iid model could be used here. However, it is desirable for the slopes (effects) to be smoothed spatially. Note that the priors you suggested seem reasonable for the scaled (standardized) covariate values I'm using.

Thanks,

John

Helpdesk

unread,
Apr 28, 2021, 3:32:27 AM4/28/21
to John Molitor, R-inla discussion group
the 'confounding' issue is always there, and here is a recent discussion
of it


@Article{art644,
author = {S. H. S{\o}rbye and J. B. Illian and D. P. Simpson and
D. Burslem and H. Rue},
title = {Careful prior specification avoids incautious
inference for log-{G}aussian {C}ox point processes},
journal = JRSSC,
year = 2019,
volume = {68},
number = {3},
pages = {543--564},
doi = {10.1111/rssc.12321},


I'm aware of making the spatial component be orthogonal to the
covariates, which is simply to add those, X, say, to the extraconstr

f(..., extraconstr=list(A=X, e=...)))

and we do not need to invent any new 'algorithms' that some seems to
suggests.

I am less convinced that this approach is the way to go in general, and
tend more to think that its a feature of the model formulation that we
have to deal/live with. it does not mean that for simple covariates,
lat/long, f.ex, this could be useful.

Best
H

John Molitor

unread,
Apr 29, 2021, 1:30:59 AM4/29/21
to R-inla discussion group
Thank you very much for this. Regarding adding a constraint to implement Restricted Spatial Regression (RSR), I'm a little confused about dimension issues. Here's some code for a super simple iid model. (I know that RSR is not really needed here, I'm just trying to understand coding issues.)

I'm simply fitting:

y_i = alpha_(r_i) + beta*x + error_i, where r_i=r, the region to which individual i belongs.

alpha_r = alpha.0 + error_alpha_r

--------------------------------------------------

require(INLA)

rm(list=ls())
set.seed(1)

N <- 100

num.grps <- 10
grp <- sample(1:num.grps,N,rep=T)

sd.alpha <- 1
alpha.0 <- 3
alphas <- rnorm(num.grps,alpha.0,sd.alpha)

beta <- 0.2

x <- rnorm(N)
y <- alphas[grp] + beta * x + rnorm(N,sd=0.1)

dat <- data.frame(x,y)

require(INLA)
f <- y ~ 1 + f(grp,model="iid") + x
mod.inla <- inla(f,data=dat)

X <- mod.inla$model.matrix

P <- X %*% solve(t(X)%*%X) %*% t(X)
A.rsr <- diag(nrow(P)) - P
e.rsr <- rep(0,nrow(A.rsr))

f.rsr <- y ~ 1 + f(grp,
                   extraconstr=list(A=as.matrix(A.rsr),
                                    e=rep(0,nrow(A.rsr))),
                   ) + x


## Dimension Error
mod.inla.rst <- inla(f.rsr,data=dat)

Helpdesk

unread,
Apr 29, 2021, 5:41:17 AM4/29/21
to John Molitor, R-inla discussion group

this is also related to the post
[r-inla] Modelling continuous covariates using RW2 latent model

about 'values', which defines for which values the model is defined for.
you need to control this yourself, like I do in the code. Its easy if
num.grp is eq to N, but I guess you can revert some of the changes I did
(which I thought caused the problems), before realising that the random
dimension of the iid model was the issue.

H
runme.R
Message has been deleted
Message has been deleted

John Molitor

unread,
Apr 29, 2021, 4:55:44 PM4/29/21
to R-inla discussion group
Thanks again for this. All is fine with the iid model, but when I use a spatial model (e.g. bym or besag) using your code, I again get a dimension error, even using "values=1:N".

I suppose the dimension of the graph is an issue? Note that A has N columns while the graph will have size of num.grp.

Of course it will work if I create an A matrix derived from an X matrix with binned covariate values so the number of rows of X equals num.grp. This can be achieve by using, within each grp, median values for continuous covariates or perhaps modal values for categorical covariates. However it would seem that I would lose a lot of information this way.

John

Helpdesk

unread,
May 2, 2021, 3:21:21 AM5/2/21
to John Molitor, R-inla discussion group

its only an 'error' in the sense that the input is wrong or
inconsistent, and the code detect that and cannot move on. it should be
easy to fix if understanding the issue at hand.

if you have a regional model like besag (not bym, which make less sense
in this context), then you cannot make it orthogonal to covariates,
unless you have one covariate pr region. with several pr region you have
to define how to make it 'in average' orthogonal.

Best
H

John Molitor

unread,
May 3, 2021, 12:18:12 AM5/3/21
to R-inla discussion group
Thanks so much for this! I got it all to work by averaging in the manner stated previously to create "average" orthogonality. Results seem reasonable.

If you could bear one more question: Does this approach work for the slopes, where the formula is of the form "...x + f(idx, x,...)"? Note my A matrix (for extraconstr) has x in it (as x is a covariate in the model) while x is also a weight in the besag random effect.

John

Helpdesk

unread,
May 3, 2021, 9:14:28 AM5/3/21
to John Molitor, R-inla discussion group
On Sun, 2021-05-02 at 21:18 -0700, John Molitor wrote:
> Thanks so much for this! I got it all to work by averaging in the
> manner stated previously to create "average" orthogonality. Results
> seem reasonable.

thx


> If you could bear one more question: Does this approach work for the
> slopes, where the formula is of the form "...x + f(idx, x,...)"? Note
> my A matrix (for extraconstr) has x in it (as x is a covariate in the
> model) while x is also a weight in the besag random effect.

yes, that should be fine. '+x' is linear in 'x' and by having weights
'x' with coefficients in f(idx...), then you say you do not want that
confounding.

one simple example is

x + f(time, x, model="rw2"...)

for which [1, x] spans the null-space of 'rw2', and then you really need
it.

H

John Molitor

unread,
May 3, 2021, 1:24:45 PM5/3/21
to R-inla discussion group
Ugh, I still have one more technical question. You've been very helpful and I appreciate it.

To establish "average orthogonality" my A matrix consists of mean values of continuous covariates per grp, and modal values of categorical covariates per group (with random selection when there are more than one mode).

For an original categorical covariate, x_cat, there may be 4 levels, 1,2,3,4. However, in the A matrix,  I may end up with only three values for this covariate, 1,2,4. Does this mess things up? Will the categories for x_cat in the A matrix (3 levels) correspond to levels for the same covariate in the data with four levels, 1,2,3,4? Or will things get relabeled somehow?

John

Helpdesk

unread,
May 4, 2021, 1:50:25 AM5/4/21
to John Molitor, R-inla discussion group

to make the spatial field orthogonal to covariates, then if its a
continous indexed field (model=spde), then only continous covariates
should be considered and only those can could have been measured
everywhere.

with a region model, then its a little different, and you can make it
orthogonal to covariates that are region spesific. and this, I guess,
could include factors as well.

if you have factors in the formula, then these are expanded and
sometimes reduced (like lm() does), [there is an alternative expansion
in 'expand.factor.strategy' in control.fixed], so I guess as you say,
this can create issues. as long as you have the same levels included in
both places, it should go fine [as the correction should be invariant to
the levels]. But if you have level 1,2,3 in the correction, and 1,2,3,4
in the model itself, then there could be an issue.

the only way (beyond the new strategy as mention) to control the
expansion of factors, is to do it yourself, by recoding factors into
vectors of numerics.

Best
H

authentic notes

unread,
May 4, 2021, 8:06:51 PM5/4/21
to R-inla discussion group
Buy Fake Euro Bills Online https://authenticnotes.com/euros/


Buy high-quality undetectable grade AA+ counterfeit banknotes & Registered Documents Online Visit: https://authenticnotes.com

We are the best and Unique producer of Super Undetectable Counterfeit Banknotes 300 million of our products circulating around the world. We offer only original high-quality counterfeit currency NOTES and Documents. We ship worldwide. We also print and sell Grade A banknotes of over 150 currencies in the world. Here is your chance to be a millionaire. Our money is perfectly reproduced, Indistinguishable to the eye and to the touch. We are sending in various sizes, packed and hidden. All our notes carry all the holograms and water marks and pass the light detector test. We will deliver the money directly to your home without the interference of customs. We have a Huge quantity ready in stock. EUROS, DOLLARS, AND POUNDS. We are Professionals in counterfeiting and we produce SUPER UNDETECTED COUNTERFEIT MONEY for all currencies. Our notes are industrially and professionally produced.


Buy real registered driver's license, Passport(whatsapp+1(318) 406-1272) identity card , SSN, Birth Certificates, Diplomas, Divorce Certificate, Gun license, Adoption Certificates, Marriage Certificate, Residence Permit, Diplomas
Buy real USA passports (http://www.authenticnotes.com) buy original passports, driver's license (WhatsApp: +1(318) 406-1272)Buy USA Green card, Buy Genuine Passport, buy residence permit, id card, visa, IELTS, NEBOSH, GMAT, GRE, citizenship


BUY SUPER HIGH QUALITY UNDETECTABLE COUNTERFEIT MONEY, DOLLARS, GREAT BRITISH POUNDS, EUROS, AND OTHER CURRENCIES.. WE ALSO SUPPLY SSD SOLUTION. WhatsApp: +1(318) 406-1272

BUY REAL GERMAN DRIVER'S LICENSE,PASSPORTS, ID CARDS , VISA https://authenticnotes.com/drivers-license/



Whatsapp......+1(318) 406-1272



We offer only Original high-quality database registered passports, Ielts Certificate, Drivers Licenses, ID cards, stamps, Visas, School Diploma, working permits, birth certificates, marriage certificates, death certificates, green cards, credit cards, bank receipts and other documents for a number of countries like USA, Australia, Belgium, Brazil, Canada, Italia, Finland, France, Germany, Israel, Mexico, Netherlands, South Africa, Spain, United Kingdom, Japan, China, and This list is not full!(http://www.authenticnotes.com)

Our Team has years of experience producing high-quality Real genuine database registered passports, database Citizenship Documents, Other Identity documents. We use high-quality equipment and materials to produce documents being registered by our insiders working in the various passport agencies. All secret features of real passports are carefully duplicated for our falsified documents. Over 17 million of our documents are circulating around the world.


Buy Real and Fake Passports Online Visit: https://authenticnotes.com/passport/























Whatsapp......+1(318) 406-1272





Buy fake and real documents online http://www.authenticnotes.com

Buy Driver's license online http://www.authenticnotes.com

Buy fake and real passports online http://www.authenticnotes.com


Buy new birth certificate http://www.authenticnotes.com

Buy documents online http://www.authenticnotes.com

Buy certificates online http://www.authenticnotes.com

Buy diplomas online http://www.authenticnotes.com

Get new id cards online http://www.authenticnotes.com

Original ielts certificates online http://www.authenticnotes.com

Buy passport online http://www.authenticnotes.com

Buy identity card online http://www.authenticnotes.com

Buy driving license online http://www.authenticnotes.com

Buy the residence permit online http://www.authenticnotes.com

resident permit for sale http://www.authenticnotes.com

apply for usa green card http://www.authenticnotes.com

buy permanent residence permit http://www.authenticnotes.com

permanent residence permit for sale http://www.authenticnotes.com

Buy/Get Citizenship Online http://www.authenticnotes.com

Obtain citizenship by investment http://www.authenticnotes.com

Buy documents online http://www.authenticnotes.com

Buy IELTS without exams online http://www.authenticnotes.com





apply for visa online http://www.authenticnotes.com


get USA visa online http://www.authenticnotes.com

acquire visa online http://www.authenticnotes.com

Buy IELTS certificate in Australia http://www.authenticnotes.com

Buy IELTS certificate in Dubai http://www.authenticnotes.com

Buy IELTS certificate in India http://www.authenticnotes.com

Buy IELTS certificate in Karachi http://www.authenticnotes.com

Buy IELTS certificate in Malaysia http://www.authenticnotes.com

Buy IELTS certificate in Nepal http://www.authenticnotes.com

Buy IELTS certificate in UAE http://www.authenticnotes.com

Buy IELTS certificate in Singapore http://www.authenticnotes.com

Buy IELTS certificate online http://www.authenticnotes.com

Buy IELTS certificate UK http://www.authenticnotes.com

Buy counterfeit money online http://www.authenticnotes.com

Buy counterfeit banknotes http://www.authenticnotes.com

Buy fake dollar banknotes http://www.authenticnotes.com

Buy fake euro banknotes http://www.authenticnotes.com

Buy fake pound banknotes http://www.authenticnotes.com

Buy fake currency online http://www.authenticnotes.com



Whatsapp......+1(318) 406-1272





we are able to produce the following items;

REGISTERED AND UNREGISTERED BRITISH PASSPORT. http://www.authenticnotes.com

REGISTERED AND UNREGISTERED CANADIAN PASSPORT. http://www.authenticnotes.com

REGISTERED AND UNREGISTERED FRENCH PASSPORT. http://www.authenticnotes.com

REGISTERED AND UNREGISTERED AMERICAN PASSPORT. http://www.authenticnotes.com

REGISTERED AND UNREGISTERED RUSSSIAN PASSPORT. http://www.authenticnotes.com

REGISTERED AND UNREGISTERED JAPANESE PASSPORT. http://www.authenticnotes.com

REGISTERED AND UNREGISTERED CHINESSE PASSPORT. http://www.authenticnotes.com


Buy Registered and Unregistered United Kingdom Passports, http://www.authenticnotes.com

Buy Registered and Unregistered http://www.authenticnotes.com

Brazilian (Brazil) Passports, http://www.authenticnotes.com

Buy Registered and unregistered Canadian (Canada) Passports, http://www.authenticnotes.com

Buy Registered and Unregistered Finnish (Finland) passports, http://www.authenticnotes.com

Buy Registered and unregistered French (France) passports, http://www.authenticnotes.com

Buy Registered and unregistered German (Germany) passports, http://www.authenticnotes.com

Buy Registered and unregistered Dutch (Netherland / Holland) passports, http://www.authenticnotes.com

Buy Registered and unregistered Israel passports, http://www.authenticnotes.com

Buy Registered and Unregistered UK (United Kingdom) http://www.authenticnotes.com

Buy Registered and Unregistered Spanish (Spain) http://www.authenticnotes.com

Buy Registered and Unregistered Mexican (Mexico) Passports, http://www.authenticnotes.com

Buy Registered and Unregistered South African Passports. http://www.authenticnotes.com

Buy Registered and Unregistered Australian Driver License, http://www.authenticnotes.com

Buy Registered and Unregistered Canadian Driver License, http://www.authenticnotes.com

Buy Registered and Unregistered French (France) Driver License, http://www.authenticnotes.com

Buy Registered and Unregistered Dutch (Netherland / Holland) Driving License, http://www.authenticnotes.com

Buy Registered and Unregistered German (Germany) Driving License , http://www.authenticnotes.com

Buy Registered and Unregistered UK (United Kingdom) Driving License, http://www.authenticnotes.com

Buy Registered and Unregistered Diplomatic Passports, http://www.authenticnotes.com

Buy Registered and Unregistered Brazilian Passports, Buy Registered and Unregistered Brazilian (Brazil) Passports,

Buy Registered and unregistered Canadian (Canada) Passports, http://www.authenticnotes.com

Buy Registered and Unregistered Finnish (Finland) Passports, http://www.authenticnotes.com

Buy Registered and unregistered French ( France) Passports, http://www.authenticnotes.com

Buy Registered and Unregistered German (Germany) Passports, http://www.authenticnotes.com

Buy Registered and Unregistered Spanish (Spain) passports, Buy Registered and Unregistered Israel Passports,
Buy Registered and Unregistered UK (United Kingdom) Passports, http://www.authenticnotes.com
Buy Registered and Unregistered Spanish (Spain) Buy Registered and unregistered South African passports. Buyer, driver, Buy Registered and unregistered Canadian licenser driver, Buy Registered and unregistered French (France) licenser driver, Buy Registered and unregistered Dutch (Netherland / Holland) driving license, Buy Registered and unregistered German (Germany) driving license



Whatsapp......+1(318) 406-1272




Buy Registered and Unregistered UK (United Kingdom) Driving License, http://www.authenticnotes.com

Buy Registered and Unregistered Diplomatic Passports, http://www.authenticnotes.com

Registered and Unregistered Passports Duplicates, http://www.authenticnotes.com

Registered and Unregistered United States Passports for sale, http://www.authenticnotes.com

Registered and unregistered Australian passports for sale, http://www.authenticnotes.com

Registered and unregistered Belgium Passports for sale, http://www.authenticnotes.com

Registered and unregistered Brazilian (Brazil) passports for sale, http://www.authenticnotes.com

buy Camouflage passports, http://www.authenticnotes.com

Express Work permits http://www.authenticnotes.com



Buy Real and Fake Passports Online Visit: https://authenticnotes.com/passport/






















Whatsapp......+1(318) 406-1272


Reply all
Reply to author
Forward
0 new messages