Difficulty with gam and step.gam

2 messages 2 people Latest: Aug 24, 2010

Difficulty with gam and step.gam

From: Mahesh Samtani Date: August 24, 2010 technical
Hello, I have 21 covariates that I would like to screen using GAM in xpose. I tried using the extra file in xpose. I couldn't figure out how to communicate with xpose and tell it to use the additional variables in the extra file as covariates during GAM. Could someone comment on how to use the extra file in xpose? As a work around to the above problem; I tried to hard code step.gam with 21 explanatory variables in R. I ran into a problem again with the "Error: cannot allocate vector of size 437.9 Mb". This problem comes up if the list of explanatory variables is longer than 17. I have to comment out 4 of the variables and can't test more than 17 variables at a time (see below). I am wondering if there is a work around this problem or should I run the steps of a step.gam manually in R? Please help, Mahesh gam.object <- gam(YVAR~1, data=gam.data) step.object <-step.gam(gam.object, scope=list( "FAC1"=~1+FAC1, "FAC2"=~1+FAC2, "FAC3"=~1+FAC3, "NUM1"=~1+NUM1+ns(NUM1,df=2), "NUM2"=~1+NUM2+ns(NUM2,df=2), "NUM3"=~1+NUM3+ns(NUM3,df=2), "NUM4"=~1+NUM4+ns(NUM4,df=2), "NUM5"=~1+NUM5+ns(NUM5,df=2), "NUM6"=~1+NUM6+ns(NUM6,df=2), "NUM7"=~1+NUM7+ns(NUM7,df=2), "NUM8"=~1+NUM8+ns(NUM8,df=2), "NUM9"=~1+NUM9+ns(NUM9,df=2), "NUM10"=~1+NUM10+ns(NUM10,df=2), "NUM11"=~1+NUM11+ns(NUM11,df=2), "NUM12"=~1+NUM12+ns(NUM12,df=2), "NUM13"=~1+NUM13+ns(NUM13,df=2),"NUM14"=~1+NUM14+ns(NUM14,df=2) #"NUM15"=~1+NUM15+ns(NUM15,df=2), #"NUM16"=~1+NUM16+ns(NUM16,df=2), #"NUM17"=~1+NUM17+ns(NUM17,df=2), #"NUM18"=~1+NUM18+ns(NUM18,df=2) ))

Re: Difficulty with gam and step.gam

From: Venkatesh. P Date: August 24, 2010 technical
Dear Mahesh, The problem ("Error: cannot allocate vector of size 437.9 Mb") you are facing could be related to memory of R. Though, I never used GAM function in R. I had same type of problem when I was trying to read 2GB size simulated dataset. May be following solution might work. You can increase the memory of R by 1. Right-click on your R program icon (the icon on your desktop or in your programs directory). Select ``Properties'', and then select the ``Shortcut'' tab. Look for the ``Target'' field and after the closing quotes around the location of the R executible, add --max-mem-size=500M as shown in the figure below.. If you get the error that R cannot allocate a vector of length x, close out of R and add the following line to the ``Target'' field: --max-vsize=500M or as appropriate. You can always check to see how much memory R has available by typing at the R prompt > round(memory.limit()/2^20, 2) which gives you the amount of available memory in MB. 2. If you have lower RAM capacity then you may have to install additional RAM and then reinstall R in order to take advantage of the additional capacity to the maximum amount of physical RAM you have installed. Best Regards, Venkatesh Pilla Reddy PhD Fellow, Dept. of Pharmacokinetics, Toxicology and Targeting, University of Groningen, Antonius Deusinglaan 1, 9713 AV Groningen, The Netherlands Office Tel: +31 50 363 7627 Mobile Phone: +31 61 988 3918 Room: (3211) 473 Email: [email protected] --- On Tue, 24/8/10, Samtani, Mahesh [PRDUS] <[email protected]> wrote:
Quoted reply history
From: Samtani, Mahesh [PRDUS] <[email protected]> Subject: [NMusers] Difficulty with gam and step.gam To: [email protected] Date: Tuesday, 24 August, 2010, 7:52 PM Hello, I have 21 covariates that I would like to screen using GAM in xpose. I tried using the extra file in xpose. I couldn't figure out how to communicate with xpose and tell it to use the additional variables in the extra file as covariates during GAM. Could someone comment on how to use the extra file in xpose? As a work around to the above problem; I tried to hard code step.gam with 21 explanatory variables in R. I ran into a problem again with the "Error: cannot allocate vector of size 437.9 Mb". This problem comes up if the list of explanatory variables is longer than 17. I have to comment out 4 of the variables and can't test more than 17 variables at a time (see below). I am wondering if there is a work around this problem or should I run the steps of a step.gam manually in R? Please help, Mahesh gam.object <- gam(YVAR~1, data=gam.data) step.object <-step.gam(gam.object, scope=list( "FAC1"=~1+FAC1, "FAC2"=~1+FAC2, "FAC3"=~1+FAC3, "NUM1"=~1+NUM1+ns(NUM1,df=2), "NUM2"=~1+NUM2+ns(NUM2,df=2), "NUM3"=~1+NUM3+ns(NUM3,df=2), "NUM4"=~1+NUM4+ns(NUM4,df=2), "NUM5"=~1+NUM5+ns(NUM5,df=2), "NUM6"=~1+NUM6+ns(NUM6,df=2), "NUM7"=~1+NUM7+ns(NUM7,df=2), "NUM8"=~1+NUM8+ns(NUM8,df=2), "NUM9"=~1+NUM9+ns(NUM9,df=2), "NUM10"=~1+NUM10+ns(NUM10,df=2), "NUM11"=~1+NUM11+ns(NUM11,df=2), "NUM12"=~1+NUM12+ns(NUM12,df=2), "NUM13"=~1+NUM13+ns(NUM13,df=2),"NUM14"=~1+NUM14+ns(NUM14,df=2) #"NUM15"=~1+NUM15+ns(NUM15,df=2), #"NUM16"=~1+NUM16+ns(NUM16,df=2), #"NUM17"=~1+NUM17+ns(NUM17,df=2), #"NUM18"=~1+NUM18+ns(NUM18,df=2) ))