rsquaredacademy / olsrr

Tools for developing OLS regression models
https://olsrr.rsquaredacademy.com/
Other
101 stars 22 forks source link

error while using olsrr function: #206

Open kathywr opened 1 year ago

kathywr commented 1 year ago

Hello, I am using ols_step_forward_aic function from olsrr package to do stepwise AIC forward regression but I am getting an error: I have attached my datasets for reference:

dput(combine_df[1:5,1:52])
structure(list(ENSG00000130943.6 = c(-0.0814098051060948, 0.206379671030366, 
0.321031350919992, 0.513621983895094, 0.659905091586951), rs1 = c(2L, 
0L, 1L, 0L, 0L), rs2 = c(2L, 0L, 1L, 0L, 0L), rs3 = c(2L, 0L, 
1L, 1L, 1L), rs4 = c(0L, 0L, 0L, 0L, 0L), rs5 = c(0L, 0L, 0L, 
1L, 0L), rs6 = c(1L, 0L, 1L, 0L, 0L), rs7 = c(0L, 0L, 1L, 1L, 
0L), rs8 = c(0L, 0L, 0L, 0L, 0L), rs9 = c(0L, 0L, 0L, 0L, 0L), 
    rs10 = c(0L, 2L, 2L, 2L, 1L), rs11 = c(2L, 1L, 1L, 1L, 2L
    ), rs12 = c(2L, 1L, 0L, 1L, 0L), rs13 = c(0L, 1L, 0L, 0L, 
    0L), rs14 = c(0L, 1L, 0L, 0L, 0L), rs15 = c(0L, 0L, 0L, 1L, 
    0L), rs16 = c(0L, 0L, 0L, 0L, 0L), rs17 = c(0L, 1L, 0L, 0L, 
    0L), rs18 = c(0L, 1L, 0L, 0L, 0L), rs19 = c(0L, 2L, 1L, 2L, 
    2L), rs20 = c(0L, 2L, 1L, 2L, 2L), rs21 = c(0L, 0L, 1L, 0L, 
    0L), rs22 = c(0L, 0L, 0L, 0L, 0L), rs23 = c(0L, 0L, 1L, 0L, 
    0L), rs24 = c(0L, 0L, 1L, 0L, 0L), rs25 = c(0L, 0L, 0L, 0L, 
    0L), rs26 = c(0L, 0L, 1L, 0L, 0L), rs27 = c(2L, 1L, 1L, 2L, 
    2L), rs28 = c(0L, 0L, 1L, 0L, 0L), rs29 = c(0L, 0L, 1L, 0L, 
    0L), rs30 = c(0L, 0L, 1L, 0L, 0L), rs31 = c(0L, 0L, 1L, 0L, 
    0L), rs32 = c(0L, 0L, 1L, 0L, 0L), rs33 = c(0L, 0L, 1L, 0L, 
    0L), rs34 = c(0L, 0L, 1L, 0L, 0L), rs35 = c(0L, 0L, 1L, 0L, 
    0L), rs36 = c(0L, 0L, 1L, 0L, 0L), rs37 = c(0L, 0L, 1L, 0L, 
    0L), rs38 = c(0L, 0L, 1L, 0L, 0L), rs39 = c(0L, 0L, 0L, 1L, 
    0L), rs40 = c(0L, 2L, 1L, 1L, 1L), rs41 = c(2L, 2L, 2L, 1L, 
    2L), rs42 = c(0L, 2L, 2L, 1L, 2L), rs43 = c(0L, 2L, 2L, 1L, 
    2L), rs44 = c(2L, 1L, 1L, 0L, 0L), rs45 = c(0L, 0L, 0L, 0L, 
    0L), rs46 = c(0L, 0L, 1L, 0L, 0L), rs47 = c(1L, 0L, 0L, 1L, 
    1L), rs48 = c(2L, 0L, 0L, 1L, 1L), rs49 = c(0L, 0L, 1L, 0L, 
    0L), rs50 = c(0L, 0L, 0L, 0L, 1L), rs51 = c(0L, 0L, 0L, 0L, 
    0L)), row.names = c("GTEX-1117F", "GTEX-111FC", "GTEX-1128S", 
"GTEX-117XS", "GTEX-1192X"), class = "data.frame")
model <- lm(ENSG00000130943.6 ~ ., data = combine_df)
> ols_step_forward_aic(model)
Error in if (aics[minaic] < laic[lpreds]) { : 
  the condition has length > 1
aravindhebbali commented 1 year ago

Hi.. Please share the combine_df() function as well so that we can reproduce the error.