Question: n issue with my code - same code, same data, different day and broken code

Hello!

I am currently trying to wrap up my masters project and while taking a look at my code with my prof yesterday we noticed something very strange - when I ran the code from months ago (that worked on several occasions and I know for sure was correct) it started giving different results. Not "oh you used a different set.seed() results", but results that are just not the same as what I had before.

A little bit about the project - it is a simulation in which I create my own data using runif() and rbern(0) functions, so the answers always vary a little bit. I also then use a replicate(0) function so of course non of my answers will be identical, but the new results I get are simply wrong.

I tried re-installing Rstudio, using R console, a different computer and the online Rstudio, but the code still gives me the wrong results!

I know that the code is right and I have no idea what's happening. If anyone knows any possible reason for why this is happening and what I can do, I would really appreciate it. Any suggestion would be life saving!

P.S. let me now if you need to see any of the code for reference!

This could be an issue with package dependencies changing/updating. Can you post the results of sessionInfo()?

Also, have you been able to pinpoint where in the code the differences arise? If not some of the code, the expected, and the actual results would be helpful.

1 Like

Hello! Here are the results for when I call sessionInfo():

Yes, there is an issue with just one part it seems. I am using the function stratcox <- coxph(Surv(time,d)~x,weights=(1/p),data=dfs) where all the variables/data is defined correct (and is the same as what I saw before). This function uses the package 'survival' and I guess there is something wrong with it, but I cannot figure out what.

The issue that I'm seeing is that normally, when I would call stratcox$var, I would get a value around 0.08, but now I'm getting something like 0.13, which throws off all my further calculations.

It looks like there have been several updates to survival that affect coxph and improvements to how it calculates variance.

I would drop back to an older version to see if that gives you the results you are expecting. Its hard to say which one would give you the results you were getting before. devtools::install_version("survival", version = "3.0") might be a good place to start.

If this is a bug/issue that you are able to isolate, I'm sure an issue raised on the GitHub would be appreciated. I don't see anything that mentions your issue there currently.

I tried installing the older version 3.2-3, but I am still getting those wonky results - any other possible suggestions? I am really grasping at straws here!

It looks like 3.2-3 was the version you already had installed looking at your sessionInfo. Have you tried other versions?

Version 3.1-12 was a version that changed how variance would be calculated when a weight is given. Does version 3.1-11 still result in the different results?

This topic was automatically closed 21 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.