s-news
[Top] [All Lists]

function

To: s-news@lists.biostat.wustl.edu
Subject: function
From: Pravin Jadhav <pravinj@gmail.com>
Date: Thu, 17 Feb 2005 17:23:06 -0500
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=OFWAjgChYFgFRFD/Abwjc8HZyJ9w1/DaFWUU+8ibyXUInAeJ5ellHjEe6Z76pW9MF1z4m0pw5ORDU0oy/keii7jLVO5BcCooVICCpsZ7yi2ZxckEKlNWGDDxSZOibYmGIbUJeb9y7b7r4XtOylk2VeCOyiAv89l5lSdbrtXscvg=
Reply-to: Pravin Jadhav <pravinj@gmail.com>
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 <=