1
$\begingroup$

I'm working with cox models and as I am adding more variables, I am facing a memory issue. I tried to subset my dataframe by selecting columns which have variables of interest but even then I am facing this problem. How can I overcome that?

My data has around 451,557 observations with 270 variables. 70 Percent of variables are categorical (strings).

coxdf_2<- coxph(surv_df ~ NS_group + age_at_recruitment + Gender + Alcohol_drinking + 
                              Smoking + Diabetes + BMI +  +Hypertention, 
                method="breslow", data = DFMODEL)

Error: cannot allocate vector of size 16.1 Gb

coxdf_3<- coxph(surv_df ~ NS_group + SOC+ towndep_I + Education+age_at_recruitment + 
                          Gender + Alcohol_drinking  + Smoking + Diabetes + BMI +  
                          +Hypertention,
                method="breslow", data = DFMODEL)

Error: cannot allocate vector of size 24.4 Gb

$\endgroup$
0

1 Answer 1

0
$\begingroup$

If you're using a 64-bit version of R on Windows (I'm not sure about other operating systems), then you can allocate additional memory to R with memory.limit function.

memory.limit(size = 25000) ## limit is set based on Mb

32-bit version (depending on the system, whether it is 32-bit or 64-bit) is limited to 2 to 4Gb.

You can further read about memory limits in R.

All that said, I would take a step back beforehand to make sure I actually need to deal with all that data and would investigate other alternatives.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.