Skip to content

Commit

Permalink
improve VIF and actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Polkas committed Jan 28, 2025
1 parent 6801923 commit cdf6ec9
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
push:
branches: master
branches: main

name: pkgdown

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

name: test-coverage

Expand Down
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ importFrom(data.table, as.data.table)
importFrom(data.table, setDT)

useDynLib(miceFast,.registration=TRUE)
export(corrData)
export(miceFast)

export(neibo)

Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* fixed CRAN Notes.
* style the cpp code.
* VIF() should be more stable.

# miceFast 0.8.2

Expand Down
7 changes: 4 additions & 3 deletions R/VIF.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ VIF <- function(x, posit_y, posit_x, correct = FALSE) {
VIF.data.frame <- function(x, posit_y, posit_x, correct = FALSE) {
x_small <- x[, c(posit_y, posit_x)]
x_small[[1]] <- as.numeric(x_small[[1]])
xx <- model.matrix.lm(~.-1, x_small, na.action = "na.pass")
xx <- model.matrix.lm(~., x_small, na.action = "na.pass")
aa <- attributes(xx)$assign
ll <- 2:ncol(xx)
VIF_(xx, 1, ll, aa[ll], correct)
ll <- 3:ncol(xx)
VIF_(xx, 2, ll, aa[ll], correct)
}

#' @describeIn VIF
Expand All @@ -109,6 +109,7 @@ VIF.data.table <- function(x, posit_y, posit_x, correct = FALSE) {

VIF.matrix <- function(x, posit_y, posit_x, correct = FALSE) {
x_small <- x[, c(posit_y, posit_x)]
stopifnot(is.numeric(x_small))
ncol_x <- ncol(x_small)
VIF_(x_small, 1, 2:ncol_x, 2:ncol_x, correct)
}
Binary file added Rplots.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion man/VIF.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/R_funs.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <RcppArmadillo.h>
#include "miceFast.h"
#include <math.h>
#include "miceFast.h"

arma::uvec get_index_full_R(arma::mat &x, int posit_y, arma::uvec posit_x) {
arma::colvec y_col = x.col(posit_y);
Expand Down
Binary file modified tests/testthat/Rplots.pdf
Binary file not shown.
28 changes: 13 additions & 15 deletions vignettes/miceFast-intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,21 @@ upset_NA(air_miss, 6)

### Intro: dplyr

```{r,echo=TRUE}
```{r, echo=TRUE}
# VIF - values bigger than 10 (around) suggest that there might be a collinearity problem.
# VIF is high for Solar.R and x_character which is obvious - x_character is a factor version of numeric Solar.R
air_miss %>%
do(vifs = VIF(.,
posit_y = "Ozone",
posit_x = c(
"Solar.R",
"Wind",
"Temp",
"x_character",
"Day",
"weights",
"groups"
)
)) %>%
unlist()
VIF(air_miss,
posit_y = "Ozone",
posit_x = c(
"Solar.R",
"Wind",
"Temp",
"x_character",
"Day",
"weights",
"groups"
)
)
# IMPUTATIONS
air_miss <- air_miss %>%
Expand Down

0 comments on commit cdf6ec9

Please sign in to comment.