Open nathgeig opened 3 years ago
Hi @nathgeig, can you tell me what you tried/what error you got? r2mlm
works with tibbles for me; it converts tibbles to dataframes automatically using as.data.frame()
.
You're right - this fixed the error on one (simple) model but for my more complex model it just ran for 24 hours and then gave the same error message. With lmer, it is:
Error: Must group by variables found in .data
. * Column cntry
is not
found. Backtrace: 1. r2mlm::r2mlm(model.main) 7.
dplyr:::group_by.data.frame(., .data[[cluster_variable]]) 8.
dplyr::group_by_prepare(.data, ..., .add = .add)
On 3/8/2021 11:03 AM, Mairead Shaw wrote:
Hi @nathgeig https://github.com/nathgeig, can you tell me what you tried/what error you got? |r2mlm| works with tibbles for me; it converts tibbles to dataframes automatically using |as.data.frame()|.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mkshaw/r2mlm/issues/49#issuecomment-792858641, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATDL5V2ZKYRL74GFY3VHZX3TCTYOLANCNFSM4YWBYQGA.
--
Nathaniel Geiger Assistant Professor of Environmental Communication, The Media School Affiliated with Integrated Program for the Environment (IPE) Affiliated with School of Public and Environmental Affairs (SPEA) Indiana University Bloomington
Hmm, odd. Can I see what model you ran? Or, if possible, data & code for a reproducible example.
The model is as follows:
model.int <- lmer(cc_sal ~ age_gmc*(lto_std + lr_cnmean) + (1 + age_gmc|cntry), data = data, control = lmerControl(optimizer ='bobyqa', optCtrl=list(maxfun=2e5)))
Where all variables besides "cntry" are numeric, and I reformatted in various ways to make sure that they were. I was having issues with other models using the same dataset too. The dataset has 23 countries ("cntry") and ~35,000-43000 observations (some observations have missing data on some variables). Hoping to clean up the dataset and code to upload soon, I can share the link with you privately when I do.
On 3/8/2021 2:04 PM, Mairead Shaw wrote:
Hmm, odd. Can I see what model you ran? Or, if possible, data & code for a reproducible example.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mkshaw/r2mlm/issues/49#issuecomment-792997403, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATDL5V42S4Z3KKOGPHX3NCLTCUNUZANCNFSM4YWBYQGA.
Got it. Let me know when you have the dataset and code, and I'll dig in to see where the error is coming from.
Sorry for the delay – the data files and code are available under https://osf.io/srgpy/ . Let me know if there’s anything I can clean up to make it easier on your end.
From: Mairead Shaw @.> Sent: Friday, March 12, 2021 5:14 PM To: mkshaw/r2mlm @.> Cc: nathgeig @.***> Subject: Re: [mkshaw/r2mlm] r2mlm doesn't work with tibbles (#49)
Got it. Let me know when you have the dataset and code, and I'll dig in to see where the error is coming from.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mkshaw/r2mlm/issues/49#issuecomment-797786823 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ATDL5V4M6PTXEK44TLPW3E3TDJ72VANCNFSM4YWBYQGA . https://github.com/notifications/beacon/ATDL5V3M7JR2Y5HFGBPMTRTTDJ72VA5CNFSM4YWBYQGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOF6GUFRY.gif
@nathgeig Thanks for sending that along! I'm in crunch time on some other projects, but I'll take a look in a month or so.
Sounds good – good luck with your projects!
From: Mairead Shaw @.> Sent: Saturday, March 27, 2021 6:03 PM To: mkshaw/r2mlm @.> Cc: nathgeig @.>; Mention @.> Subject: Re: [mkshaw/r2mlm] r2mlm doesn't work with tibbles (#49)
@nathgeig https://github.com/nathgeig Thanks for sending that along! I'm in crunch time on some other projects, but I'll take a look in a month or so.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mkshaw/r2mlm/issues/49#issuecomment-808808757 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ATDL5V4YYFQHQ3FTLK73SK3TFZI23ANCNFSM4YWBYQGA . https://github.com/notifications/beacon/ATDL5V53PZDVMDEOPCRUUODTFZI23A5CNFSM4YWBYQGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGA2XCNI.gif
@nathgeig I'm back working on this issue! I think I've solved it -- can you download the development version using devtools::install_github("mkshaw/r2mlm")
and let me know if it works for you, too?
I'll note that I think your variables are not centered-within-country, so only one bar graph will show up. That's a function of the R-squared framework itself: in order to decompose variance completely into within- and between-cluster variance, you need to center your variables within cluster (in your case, within country). Otherwise, level-1 variables can vary both within- and between-country.
Spent a couple hours troubleshooting and realized that my dataframe was actually a tibble, which was leading r2mlm to give an error when I tried to put my model into it. Different errors with lme vs. lmer, but didn't seem to work with either. I wonder if r2mlm could be set up to recognize tibbles?