Closed LaraVolski closed 4 years ago
The error in line 52 is an unrelated issue... I think it is because when you load library(MASS)
in the foxlights_data_analysis script, it masks the select function from dplyr. See this warning message:
library(MASS)
Attaching package: ‘MASS’
The following object is masked from ‘package:dplyr’:
select
To address this, you can specify the package that is associated with the function: dplyr::select(-c(Latitude, Longitude))
At least I'm pretty sure that is the problem!
That doesn't fix the fact that I get FoxlightFoxY:rugged25.clean Estimate = 0.2531
hmmm? What is your estimate?
That fixed it! And now my interaction term is 0.2531 :) Thank you Kaitlyn!
Great! I think that this error resulted in you using the unscaled version of the metadata in your models, perhaps?
At any rate, this situation highlights a lesson about coding reproducibly... Can be summed up as "one task, one script" - try to work from one script at a time. When you run multiple scripts, it can mess up the libraries loaded, variables in the environment with the same name that overwrite each other, etc.
If you find yourself opening up a script and running only part of it, pull this into a separate script. If you find yourself running parts of two scripts together, pull them into the same script.
And to get in a good habit, restart R when you open a new script.
This all ensures that you and your colleagues will be able to reproduce your results with the same packages and objects in your environment!
https://github.com/LaraVolski/Foxlights/blob/52cfdcaa0f16ea3799bc7a8b6ddd8423ad453d70/foxlight_model_selection.Rmd#L185
When I restart Rstudio and open from scratch, I first run lines 1 - 136 in foxlights_data_analysis.Rmd. If this is all I do, and then I run fit8, I get an interaction term of 0.21 (whereas you stated that you get an interaction term of 0.25).
If after running the lines in foxlight_data_analysis.Rmd, I then run lines 10 - 108 in foxlight_model_selection.Rmd, I get an error at line 52 that says 'Error in select(., -c(Latitude, Longitude)) : unused argument (-c(Latitude, Longitude)).'
I'm thinking the reason you may be getting 0.25 and I may be getting 0.21 for fit 8 is because of the error in line 52! I am not sure how to troubleshoot this issue.