[R] nlme trouble
Francisco J. Zagmutt
gerifalte28 at hotmail.com
Sat Apr 21 00:25:50 CEST 2007
I didn't look at your code closely but I suspect you are taking the log
of zeros, hence the NA/NaN/Inf error you are getting...
Francisco
Chris Myers wrote:
> I am not certain how nlme works so I followed an example from the web (
> http://www.menne-biomed.de/gastempt/gastempt1.html). I was able to
> successfully reproduce the example. However, when I modified my the example
> to use my data and with my formula, I get a set of errors having to do with
> the log() function. I get 10 of them (all exactly the same) and there are 10
> levels in my factor variable. This seems significant to me.
>
> Below is a list of the code I modified with comments that should help
> understand what I am trying to do. If you enter the code in order from top
> to bottom you will recreate what I did. If you think that the data is at
> fault and want to see it, I can provide it. Also, under the code is the
> errors that I get when I run the nlsList function.
>
> Also, can nlme handle more than one independent at a time?
> And I was wondering what the "model=as.character(mCall[[1]])" line in the
> code did. Removing it does not seem to change the error that I receive.
>
> My OS is WinXP.
>
> Thank You in advance,
> Chris
>
>
>
> ###########List of the code that I modified with comments##########
>
> library(nlme)
>
> BiLinInit0= function(mCall,LHS,data)
> {
> model=as.character(mCall[[1]]) #I don't know what this does
>
> a <- tan(pi/4) # 45 degree angle (rising slope)
> b <- -tan(pi/4) # 45 degree angle (desending slope)
> c <- 0 # intercept
> nu <- 0.434
> xy <- sortedXyData(mCall[["x"]], LHS, data)
> x <- xy[["x"]]
> x0 <- (min(x)+max(x))/2 + nu*((log(a, exp(1)) - log(b, exp(1))))/(a+b)
> #log defaults to base e
>
> value = c(nu,a,b,c,x0)
> names(value)=mCall[c("nu","a","b","c","x0")]
> value
> }
>
> SSBiLin=selfStart(~-nu*log(exp(-a*(x-x0)/nu)+exp(b*(x-x0))/nu, exp(1))+c,
> initial=BiLinInit0, parameters= c("nu","a","b","c","x0")) #log
> defaults to base e, but I used exp(1) just to be sure (tried with just
> log(x) as well)
>
> ge = read.table("G:\\SSNon-Linear\\BINDING DATA fixed DESCRIPTORS
> ONLY.csv",sep=",",header=TRUE)
> #Load in my data set
>
> ge$study = as.factor(ge$study) #Force study to be
> a factor variable
>
> gelist = nlsList(RBA~SSBiLin(Molecular.Volume,nu,a,b,c,x0)|study,data=ge)
> #This is where I get the error
>
> contr = nlmeControl(pnlsTol=0.3)
> ge0.nlme=nlme(gelist,control=contr,verbose=F)
>
>
> ##########Errors#######################
>
>> gelist = nlsList(RBA~SSBiLin(Molecular.Volume,nu,a,b,c,x0)|study,data=ge)
> Error in qr(attr(rhs, "gradient")) : NA/NaN/Inf in foreign function call
> (arg 1)
> In addition: Warning message:
> NaNs produced in: log(x, base)
> Error in qr(attr(rhs, "gradient")) : NA/NaN/Inf in foreign function call
> (arg 1)
> In addition: Warning message:
> NaNs produced in: log(x, base)
> Error in qr(attr(rhs, "gradient")) : NA/NaN/Inf in foreign function call
> (arg 1)
> In addition: Warning message:
> NaNs produced in: log(x, base)
> Error in qr(attr(rhs, "gradient")) : NA/NaN/Inf in foreign function call
> (arg 1)
> In addition: Warning message:
> NaNs produced in: log(x, base)
> Error in qr(attr(rhs, "gradient")) : NA/NaN/Inf in foreign function call
> (arg 1)
> In addition: Warning message:
> NaNs produced in: log(x, base)
> Error in qr(attr(rhs, "gradient")) : NA/NaN/Inf in foreign function call
> (arg 1)
> In addition: Warning message:
> NaNs produced in: log(x, base)
> Error in qr(attr(rhs, "gradient")) : NA/NaN/Inf in foreign function call
> (arg 1)
> In addition: Warning message:
> NaNs produced in: log(x, base)
> Error in qr(attr(rhs, "gradient")) : NA/NaN/Inf in foreign function call
> (arg 1)
> In addition: Warning message:
> NaNs produced in: log(x, base)
> Error in qr(attr(rhs, "gradient")) : NA/NaN/Inf in foreign function call
> (arg 1)
> In addition: Warning message:
> NaNs produced in: log(x, base)
> Error in qr(attr(rhs, "gradient")) : NA/NaN/Inf in foreign function call
> (arg 1)
> In addition: Warning message:
> NaNs produced in: log(x, base)
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list