[R] Need help for nlme

Andrew Robinson A.Robinson at ms.unimelb.edu.au
Sun May 25 22:24:51 CEST 2008


My advice is to try to simplify this as much as possible.  When it is
as simple as possible, it will either work or not work.  If it works,
then you have learned something useful.  If it does not work, then
send your question again.  Right now there is a great deal of detail
that may or may not be extraneous.  

Andrew.


On Sun, May 25, 2008 at 01:36:49PM -0500, ctu at bigred.unl.edu wrote:
> Hi everyone,
> I try to write a module based on nlme however R always shows me the  
> error message
> Error in eval(expr, envir, enclos) : object "y" not found. Does anyone  
> know how to solve this? There is no problem in nls at all.
> 
> require(nlme)
> AMPmixed<-function(y, x, S1=c("asymptotic","logistic"),  
> S2=c("asymptotic","logistic"), data, start,random)
>      {
>       logist.logist<-function(x,alpha,delta,psi.l,tau.l,gamma,h){
>                   
> delta+(alpha-delta+gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))}
>       logist.asymp<-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){
>                   
> delta+(alpha-delta)/(1+exp(-(x-tau.l)/psi.l))+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)}
>       asymp.asymp<-function(x,alpha,delta,lpsi.a,gamma,h){
>                   
> delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))*exp(-exp(1/lpsi.a)*x)}
>       asymp.logist<-function(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h){
>                   
> delta+(alpha-delta)*exp(-exp(1/lpsi.a)*x)+(gamma*(x-(h-1))/exp(x))/(1+exp(-(x-tau.l)/psi.l))}
> 
>            (logistic.logistic<-function(y, x, data, start, random){
>             
> nlme.out<-nlme(y~logist.logist(x,alpha,delta,psi.l,tau.l,gamma,h),  
> data=data, start=start,
>                           fixed=alpha+delta+psi.l+tau.l+gamma+h~1,  
> random=random)
>            list(nlme.out=summary(nlme.out))
>            })
>            (logistic.asymptotic<-function(y, x, data, start, random){
>              
> nlme.out<-nlme(y~logist.asymp(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h),  
> data=data, start=start,
>                              
> fixed=alpha+delta+psi.l+tau.l+lpsi.a+gamma+h~1, random=random)
>              list(nlme.out=summary(nlme.out))
>            })
>            (asymptotic.logistic<-function(y, x, data, start,random){
>             
> nlme.out<-nlme(y~asymp.logist(x,alpha,delta,psi.l,tau.l,lpsi.a,gamma,h),  
> data=data, start=start,
>                             
> fixed=alpha+delta+psi.l+tau.l+lpsi.a+gamma+h~1, random=random)
>                 list(nlme.out=summary(nlme.out))
>            })
>            (asymptotic.asymptotic<-function(y, x, data, start, random){
>             
> nlme.out<-nlme(y~asymp.asymp(x,alpha,delta,lpsi.a,gamma,h), data=data,  
> start=start,
>                          fixed=alpha+delta+lpsi.a+gamma+h~1,random=random)
>            list(nlme.out=summary(nlme.out))
>            })
> 
>            if(S1=="logistic" && S2=="logistic")  
> {(AMPmixed=logistic.logistic(y, x, data, start, random))}
>            else if(S1=="logistic" &&  
> S2=="asymptotic"){(AMPmixed=logistic.asymptotic(y, x, data, start,  
> random))}
>            else if(S1=="asymptotic" &&  
> S2=="logistic"){(AMPmixed=asymptotic.logistic(y, x, data, start,  
> random))}
>            else if(S1=="asymptotic" &&  
> S2=="asymptotic"){(AMPmixed=asymptotic.asymptotic(y, x, data, start,  
> random))}
>            }
> 
> #########################################################################
>       con rep biomass
> 1    0.00   1   1.126
> 2    0.32   1   1.096
> 3    1.00   1   1.163
> 4    3.20   1   0.985
> 5   10.00   1   0.716
> 6   32.00   1   0.560
> 7  100.00   1   0.375
> 8    0.00   2   0.833
> 9    0.32   2   1.106
> 10   1.00   2   1.336
> 11   3.20   2   0.754
> 12  10.00   2   0.683
> 13  32.00   2   0.488
> 14 100.00   2   0.344
> 
> iso<-read.table(file="E:\\Hormesis\\data\\isobutanol.txt", header=T)
> aa<-groupedData(biomass~con|rep, data=iso)
> van2<-AMPmixed(y=biomass, x=con, S1="asymptotic", S2="asymptotic", data=aa,
>                random=pdDiag(alpha+delta+lpsi.a+gamma+h~1),
>                start=c(alpha= 0.7954, delta= 0.3231,  lpsi.a=-0.2738,  
> gamma= 1.0366, h=0.8429))
> van2
> 
> Thank you very much in advance.
> Chunhao
> 
> ______________________________________________
> R-help at r-project.org 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.

-- 
Andrew Robinson  
Department of Mathematics and Statistics            Tel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia         Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/



More information about the R-help mailing list