Thanks to Patrick.
I was able to include formula as one of the arguments and pass to the
inner function. Somehow it was not working before I posted previous
message. S poetry was really useful.
Thanks again.
Pravin
On Fri, 18 Feb 2005 11:01:27 +0000, Patrick Burns
<pburns@pburns.seanet.com> wrote:
> Can't you rewrite the function so that you have the formula as one of
> the arguments? In S-PLUS you will need to have that as an argument
> of the inner function as well.
>
> You may be interested in S Poetry.
>
> Patrick Burns
>
> Burns Statistics
> patrick@burns-stat.com
> +44 (0)20 8525 0696
> http://www.burns-stat.com
> (home of S Poetry and "A Guide for the Unwilling S User")
>
> Pravin Jadhav wrote:
>
> >Hello,
> >
> >I am writing a small function to fit an LME model.
> >
> >fit.data<-function(data) {
> > lme.fit<-by(data, data$rep, function (x) lme(resp~time,
> > data=x,
> > random=list(id=pdDiag(~1+time))))
> > return(lme.fit)
> > }
> >It WORKS for fitting response (resp) versus time for a given dataset
> >by replications (rep).
> >
> >PROBLEM: Now, I wanted to fit other variables in the same dataset. One
> >option (inefficient) was to rewrite the function for resp1,
> >resp2,.......respN and do the fitting.
> >
> >However, I would like to pass on the vector information to the
> >function used in "by". I know the following would not work..because it
> >is not supposed to...but I tried.
> >
> >fit.dataN<-function(data,vec) {
> > lme.fit<-by(data, data$rep, function (x) lme(vec~time, data=x,
> > random=list(id=pdDiag(~1+time))))
> > }
> >So that I can do the following
> >fit1<-fit.dataN(data,vec1)
> >fit2<-fit.dataN(data,vec2)
> >.............
> >fitN<-fit.dataN(data,vecN)
> >
> >Any suggestions? How to pass on the dataset as well as vector information.
> >
> >Thanks.
> >Pravin
> >
> >
> >
> >
> >
>
>
--
Pravin Jadhav
Graduate Student
Department of Pharmaceutics
MCV/Virginia Commonwealth University
DPE1/CDER/OCPB/Food and Drug Administration
Phone: (301) 594-5652
Fax: (301) 480-3212
|