s-news
[Top] [All Lists]

Re: function

To: Patrick Burns <pburns@pburns.seanet.com>
Subject: Re: function
From: Pravin Jadhav <pravinj@gmail.com>
Date: Sat, 19 Feb 2005 19:36:09 -0500
Cc: s-news@lists.biostat.wustl.edu
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=eRng2hWG8Ugv5hp0CBteQnwWk+xgHTiWUpKO3b1+wMKpHNmlgCV5/7e+ScvQ9OxBMdYI8lWItFLkHmnqxqOHMQNXYC4/gRJj+x5fZLgnyhKN4UBtXekj2XP6hgk6wP89BJTQhqeHlstIvvWlvQrOyvKR61OzRimtxqPIAQRku5U=
In-reply-to: <4215CB07.6050300@pburns.seanet.com>
References: <679f8b3f050217142367f42709@mail.gmail.com> <4215CB07.6050300@pburns.seanet.com>
Reply-to: Pravin Jadhav <pravinj@gmail.com>
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

<Prev in Thread] Current Thread [Next in Thread>
  • function, Pravin Jadhav
    • Message not available
      • Re: function, Pravin Jadhav <=