[R] Question concerning functions nlsList and nlme from nlme R library.
Jens_Praestgaard@hgsi.com
Jens_Praestgaard at hgsi.com
Mon Feb 23 14:38:18 CET 2004
I hope that the mailing list is the correct forum for the question below. I
have trouble calling functions nlsList and nlme from
another function. Any help would be greatly appreciated.
Jens Praestgaard
Human Genome Sciences
Rockville MD.
I have a data set v with two components, v$mixeddat and v$init. They are
listed below:
> v$mixeddat
conc result rep sample z
11 20.00000000 11141 1 vial 1 0
12 5.00000000 11446 1 vial 1 0
13 1.25000000 13377 1 vial 1 0
14 0.31250000 20267 1 vial 1 0
15 0.07812500 48852 1 vial 1 0
16 0.01953125 118507 1 vial 1 0
(and so on)
> v$init
a b d c cdiff
1.045617e+04 2.408045e+05 9.296929e-01 1.490621e-02 4.874540e-03
The following two lines of code fits first a nonlinear regression for each
level of rep, next a model with a random effect in one parameter.
> fit<-nlsList(result~a+(b-a)/(1+(conc/(c+z*cdiff))^d)
|rep,start=v$init,data=v$mixeddat)
> nlme(fit,random=(b~1))
However, when I try to run the same code from within a function, with this
call :
> testfunc
function(dat=v) {
test<-nlsList(result~a+(b-a)/(1+(conc/(c+z*cdiff))^d)
|rep,start=dat$init,data=dat$mixeddat)
return(nlme(test,random=b~1))
}
testfunc()
then I get the error message
Error in eval(expr, envir, enclos) : Object "result" not found
Any help would be appreciated
More information about the R-help
mailing list