Regression returns different results after updating R and R Studio

Hi R community,

today I installed the latest version of R (4.3.0) and R Studio and came under trouble with my code for a logistic regression.

  • My code predicts types of leaders (A, B) on a dataset of 409 participants .
  • When running the code in the older (4.3.2) version, I received results well above .73 for both train and test sets.
    -However, after the download I receive .62 for the test set - which is obviously a very sharp decline. I did not change the code or the data set.

I have googled this topic extensively but could not find an answer to my question.

Here is the code for the test set (for train set almost identifical except "train" instead of "test"):
#############

Splitting data into train and test data (70%, 30%)

set.seed(50)

id_train <- sample(1:409, 286, replace = FALSE)
head(id_train, 10)
data_new$id_numeric <- 1:nrow(data_new)

train_cl2 <- subset(data_new, id_numeric %in% id_train)
test_cl2 <- subset(data_new, !id_numeric %in% id_train)
dim(train_cl2)
dim(test_cl2)

#Logistic regression model

glm.leadertype <-glm(Leadertype ~.,family="binomial",data=train_cl2)
summary(glm.leadertype)

#predicting on test data using model
glm.predict.leadertype <-predict(glm.leadertype, test_cl2, type='response')
head(glm.predict.leadertype)

#convert predicted values to categories
test_cl2$predict.Leadertype <- ifelse(glm.predict.leadertype >=.5, "category A", "category B")
head(test_cl2$predict.Leadertype)

#determine accuracy of model on test
accuracy_test <-mean(test_cl2$predict.Leadertype == test_cl2$Leadertype)
accuracy_test

###########
And here's the session info:
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.utf8 LC_CTYPE=German_Germany.utf8 LC_MONETARY=German_Germany.utf8
[4] LC_NUMERIC=C LC_TIME=German_Germany.utf8

time zone: Europe/Berlin
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] compiler_4.3.0 tools_4.3.0 rstudioapi_0.14


I am very helpful for any kind of help and could also provide my dataset if necessary.

Thank you very much in advance!

Best,
Laura

Just to confirm: same seed in both?

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.