I have a model object which shows larger size in hard disk than in R. After some searching, I managed to get the problem cause as shown below
format(object.size(JMFit1$model_info$coxph_components$TermsU), units='Mb')
[1] "0 Mb"
pryr::object_size(JMFit1$model_info$coxph_components$TermsU)
28.5 MB
However JMFit1$model_info$coxph_components$TermsU
returns
>JMFit1$model_info$coxph_components$TermsU
...
attr(,".Environment")
<environment: 0x0000000025035540>
...
So, is there any way to access this environment using the reference id i.e. "0x0000000025035540" and then apply ls
for example to explore it.
Here are the questions I try Q1 and Q2, but without success. Also, I have tried ls(envir=attr(lm.fit.full$terms, ".Environment"))
from this blog but it through the following error
Error in ls(envir = attr(JMFit1$model_info$coxph_components$TermsU, ".Environment")) : invalid 'envir' argument
library(JMbayes)
MixedModelFit1 <- mvglmer(list(log(serBilir) ~ year + (year | id)), data = pbc2, families = list(gaussian))
pbc2.id$Time <- pbc2.id$years
pbc2.id$event <- as.numeric(pbc2.id$status != "alive")
CoxFit <- coxph(Surv(Time, event) ~ drug + age, data = pbc2.id, model = TRUE)
JMFit1 <- mvJointModelBayes(MixedModelFit1, CoxFit, timeVar = "year")
Many thanks in advance for any suggestion or help.
Here is a way, it does not use the ref id but it use the blog method correctly:
ls(envir=attr(JMFit1$model_info$coxph_components$TermsU$`log(serBilir)_value`, ".Environment"))
To get an object from that env we can do:
env <- attr(JMFit1$model_info$coxph_components$TermsU$`log(serBilir)_value`, ".Environment")
#To get Data for example
d <- get("Data",envir=env)
> typeof(d)
[1] "list"
> format(object.size(d),units='Mb')
[1] "2.8 Mb"
But, I'm still curious if there is a way using the ref id, especially @Spacedman said here that Trying to get R objects by their memory location is not going to work., but I hope maybe there is an update since 2014.
User contributions licensed under CC BY-SA 3.0