"paul hughes" <u7n96@hotmail.com> writes:
> I am still having problems with this function:
>
> y2<-function(n,i,v1,v2,v3,v4)
> {
> q<-c(1:n)
> a<-c(0,cumsum(rexp(n-1)))
> x<-ifelse(c(rep(c(sample(1:i)),n/i)) > i/2, 1, 0)
> t<- cumsum(c(v1,v2,v3,v4))
> s<-outer(a,t,"+")
> y<-2+3*a+4*s+5*x
> assign( "df", data.frame(q=q,a=a,x=x,s=s,y=y), 0 )
> fit1<-lme(fixed=y~a+x+s,cluster=~q,data=df)
> return(df,fit1)
> }
>
> For example:
> >y2(20,10,1,1,1,1)
s <- outer(a,t,"+") produces a matrix and hence y is also a matrix.
(The following was done in R but similar results will occur in
S-PLUS. Note that both "s" and "y" are matrices with 4 columns.
Browse[1]> str(df)
`data.frame': 20 obs. of 11 variables:
$ q : int 1 2 3 4 5 6 7 8 9 10 ...
$ a : num 0.00 2.64 2.70 3.84 4.60 ...
$ x : num 0 0 1 0 1 1 0 0 1 1 ...
$ s.1: num 1.00 3.64 3.70 4.84 5.60 ...
$ s.2: num 2.00 4.64 4.70 5.84 6.60 ...
$ s.3: num 3.00 5.64 5.70 6.84 7.60 ...
$ s.4: num 4.00 6.64 6.70 7.84 8.60 ...
$ y.1: num 6.0 24.5 29.9 32.9 43.2 ...
$ y.2: num 10.0 28.5 33.9 36.9 47.2 ...
$ y.3: num 14.0 32.5 37.9 40.9 51.2 ...
$ y.4: num 18.0 36.5 41.9 44.9 55.2 ...
Browse[1]>
Error in lme(fixed = y ~ a + x + s, cluster = ~q, data = df) :
unused argument(s) (cluster ...)
Jose Pinheiro and I, the authors of lme, recommend upgrading to the
NLME 3.3 library, available from http://nlme.stat.wisc.edu/. You are
using a very old version of lme.
Furthermore, you do not need to assign "df" to frame 0. You can pass
it directly to the call to lme if you wish.
--
Douglas Bates bates@stat.wisc.edu
Statistics Department 608/262-2598
University of Wisconsin - Madison http://www.stat.wisc.edu/~bates/
|