[R] Loop within nlme

From: Scott Story <sstory_at_montana.edu>
Date: Thu 01 Dec 2005 - 02:25:02 EST

        I am trying to mimic the SAS code below in R. The trick is that each row in the dataset has variable "t" which controls how many times the do-loop below will be iterated (that is, the model is fit to the response, ifate, 0 to t-1 times for each row of data). Is it possible to incorporate a loop like this into nlme by writing a function? Can anybody provide some hints to get me on my way? The code below is for a very simple model, an intercept only model, but more complex models will be evaluated (some potentially including random effects). The code is used to model daily nest survival.

Proc Nlmixed data=Mall tech=quanew method=gauss maxiter=1000; parms B0=0;

	p=1;
	   do i=0 TO t-1;
	   	   logit=B0;
	      p=p*(exp(logit)/(1+exp(logit)));
	   end;

model ifate~binomial(1,p);
-- 
Scott Story
Graduate Student
MSU Ecology Department
319 Lewis Hall
Bozeman, Mt 59717
406.994.2670
sstory@montana.edu

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Thu Dec 01 03:04:57 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:25 EST