Hi all, I wanted to ask if it is possible to check both continuous and categorical predictors for multi-collinearity at the same time (in one analysis, so to speak) and how I can implement this in R. If anyone can help me in this regard, I would be very pleased! Kind regards Wilma
[R-meta] Checking for Multi-Collinearity with continuous and categorial predictors
4 messages · Wilma Charlott Theilig, Wolfgang Viechtbauer
Dear Wilma, You mean in a meta-regression analysis? You can do this with metafor::vif(). After fitting a meta-regression model, you can use the vif() function to obtain variance inflation factors to indicate the degree of multicollinearity of the predictors. The predictors can be both continuous and categorical, so this works just fine. See here for the documentation (and examples): https://wviechtb.github.io/metafor/reference/vif.html Best, Wolfgang
-----Original Message----- From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces at r-project.org] On Behalf Of Wilma Charlott Theilig via R-sig-meta-analysis Sent: Saturday, 02 September, 2023 11:29 To: r-sig-meta-analysis at r-project.org Cc: Wilma Charlott Theilig Subject: [R-meta] Checking for Multi-Collinearity with continuous and categorial predictors Hi all, I wanted to ask if it is possible to check both continuous and categorical predictors for multi-collinearity at the same time (in one analysis, so to speak) and how I can implement this in R. If anyone can help me in this regard, I would be very pleased! Kind regards Wilma
2 days later
Dear Wolfgang,
first of all, thank you for your reply!
If I follow your description, I get the following error:
Error in x$terms %||% attr(x, "terms") %||% stop("no terms component nor attribute") :
no terms component nor attribute
In addition: Warning message:
In vif.default(res2) : No intercept: vifs may not be sensible.
Is there a way to fix this?
I would really appreciate your help!
Thank you so much in advance.
Best,
Wilma
Von: Viechtbauer, Wolfgang (NP) <wolfgang.viechtbauer at maastrichtuniversity.nl>
Gesendet: Samstag, 2. September 2023 13:16:07 An: R Special Interest Group for Meta-Analysis Cc: Theilig, Wilma Charlott Betreff: RE: Checking for Multi-Collinearity with continuous and categorial predictors Dear Wilma, You mean in a meta-regression analysis? You can do this with metafor::vif(). After fitting a meta-regression model, you can use the vif() function to obtain variance inflation factors to indicate the degree of multicollinearity of the predictors. The predictors can be both continuous and categorical, so this works just fine. See here for the documentation (and examples): https://wviechtb.github.io/metafor/reference/vif.html Best, Wolfgang >-----Original Message----- >From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces at r-project.org] On >Behalf Of Wilma Charlott Theilig via R-sig-meta-analysis >Sent: Saturday, 02 September, 2023 11:29 >To: r-sig-meta-analysis at r-project.org >Cc: Wilma Charlott Theilig >Subject: [R-meta] Checking for Multi-Collinearity with continuous and categorial >predictors > >Hi all, > >I wanted to ask if it is possible to check both continuous and categorical >predictors for multi-collinearity at the same time (in one analysis, so to speak) >and how I can implement this in R. > >If anyone can help me in this regard, I would be very pleased! > >Kind regards > >Wilma
Dear Wilma, In general, always provide a fully reproducible example to illustrate a problem. For example, like this: library(metafor) library(car) dat <- dat.bangertdrowns2004 res <- rma(yi, vi, mods = ~ length + wic + feedback + info + pers + imag + meta, data=dat) vif(res) So the problem arises because you are loading the 'car' package *after* you have loaded metafor and it also has a vif() function. The vif() function from metafor is then 'masked', so calling vif() calls car::vif() and not metafor::vif(). But you can always explicitly tell R which vif() function to call, like this: metafor::vif(res) Best, Wolfgang
-----Original Message-----
From: Wilma Charlott Theilig [mailto:wilma_charlott.theilig at mailbox.tu-
dresden.de]
Sent: Tuesday, 05 September, 2023 6:32
To: Viechtbauer, Wolfgang (NP); R Special Interest Group for Meta-Analysis
Subject: AW: Checking for Multi-Collinearity with continuous and categorial
predictors
Dear Wolfgang,
first of all, thank you for your reply!
If I follow your description, I?get the following error:
Error in x$terms %||% attr(x, "terms") %||% stop("no terms component nor
attribute") :
? no terms component nor attribute
In addition: Warning message:
In vif.default(res2) : No intercept: vifs may not be sensible.
Is there a way to fix this?
I would really appreciate your help!
Thank you so much in advance.
Best,
Wilma
________________________________________ Von: Viechtbauer, Wolfgang (NP) <wolfgang.viechtbauer at maastrichtuniversity.nl> Gesendet: Samstag, 2. September 2023 13:16:07 An: R Special Interest Group for Meta-Analysis Cc: Theilig, Wilma Charlott Betreff: RE: Checking for Multi-Collinearity with continuous and categorial predictors Dear Wilma, You mean in a meta-regression analysis? You can do this with metafor::vif(). After fitting a meta-regression model, you can use the vif() function to obtain variance inflation factors to indicate the degree of multicollinearity of the predictors. The predictors can be both continuous and categorical, so this works just fine. See here for the documentation (and examples): https://wviechtb.github.io/metafor/reference/vif.html Best, Wolfgang -----Original Message----- From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces at r-project.org] On Behalf Of Wilma Charlott Theilig via R-sig-meta-analysis Sent: Saturday, 02 September, 2023 11:29 To: r-sig-meta-analysis at r-project.org Cc: Wilma Charlott Theilig Subject: [R-meta] Checking for Multi-Collinearity with continuous and categorial predictors Hi all, I wanted to ask if it is possible to check both continuous and categorical predictors for multi-collinearity at the same time (in one analysis, so to speak) and how I can implement this in R. If anyone can help me in this regard, I would be very pleased! Kind regards Wilma