On Mon, Jul 12, 2010 at 8:16 AM, Jun Shen <jun.shen...@gmail.com> wrote: > Dear Deepayan, > > Thank you for taking the time to look into this issue. > > I have a data object called "Data", please find it at the end of the > message. Then I can run the code below separately in the console.
[...] > #################################################################### > > Then I have my real function as follows: If I run the code as, > >>compare.curves(Data=Data) > > The analytical part is working but not the plotting part (Error using > packet 1, object 'model' not found) I don't have much to help you, but the problem is not in lattice, but in formula.nlme. The following modification of your function also fails: compare.curves <- function(curve='ascending', Data=stop('A data object must be specified'), parameter='EC50',random.pdDiag=FALSE, start.values=c(Emax=100,E0=1,EC50=50,gamma=2),...) { mymodel=as.formula('RESP ~ E0+(Emax-E0)*CP**gamma/(EC50**gamma+CP**gamma)') mod.nlme<-nlme(model=mymodel,data=Data,method='REML', fixed=Emax+E0+EC50+gamma~1, random= if (length(parameter)==1) eval(substitute(variable~1,list(variable=as.name(parameter)))) else { variable<-as.name(parameter[1]) for (i in 2:length(parameter)) variable<- paste(variable,'+',as.name(parameter[i])) formula<-as.formula(paste(variable,'~1')) if (random.pdDiag) list(pdDiag(formula)) else formula }, groups=~ID, start=list(fixed=start.values) ) formula(mod.nlme) } -Deepayan ______________________________________________ R-help@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.