Dear R-users: I have some problems working with lme function, and i would be glad if anyone could help me. this kind of analysis i was used to do with PROC MIXED from SAS, but i would like to move to R, for many reasons... So, the problem is: Imagine the I have 3 factors: fact_A, fact_B and fact_C: The latter I would assume that is random, and the rest of them are fixed. Analysing the structure of the random factor, i found that it's necessary to set up an AR1 model. in a nutshell, it's a 3-way model, but one of the factors is random. working in SAS/ proc mixed I the program to analyside this would be: ######################## proc mixed; class fact_A fact_B fact_C; model y = fact_A fact_B; random fact_c /type=AR1; run; ######################## trying to translate this to R, I tryed after reading ?lme and trying to find any older message at r-help list. ######## library(nlme) GD = groupedData(y~1|fact_C, data=DataFrame) # as I see in the help, it's necessary to covert the data.frame in a groupedData object. lme(fixed= y~fact_A + fact_B, data=GD, random=~1|fact_+C, corr=corAR1(form~1|fact_C)) #and trying to run lme function. ######## Am i doing something wrong (or stupid)? 'cause I am not getting the same result. Thanks in advance Rodrigo. [[alternative HTML version deleted]]
Dear R-users: I have some problems working with lme function, and i would be glad if anyone could help me. this kind of analysis i was used to do with PROC MIXED from SAS, but i would like to move to R, for many reasons... So, the problem is: Imagine the I have 3 factors: fact_A, fact_B and fact_C: The latter I would assume that is random, and the rest of them are fixed. Analysing the structure of the random factor, i found that it's necessary to set up an AR1 model. in a nutshell, it's a 3-way model, but one of the factors is random. working in SAS/ proc mixed I the program to analyside this would be: ######################## proc mixed; class fact_A fact_B fact_C; model y = fact_A fact_B; random fact_C /type=AR1; run; ######################## trying to translate this to R, I tryed after reading ?lme and trying to find any older message at r-help list. ######## library(nlme) GD = groupedData(y~1|fact_C, data=DataFrame) # as I see in the help, it's necessary to covert the data.frame in a groupedData object. lme(fixed= y~fact_A + fact_B, data=GD, random=~1|fact_+C, corr=corAR1(form~1|fact_C)) #and trying to run lme function. ######## Am i doing something wrong (or stupid)? 'cause I am not getting the result that i wish. Thanks in advance Rodrigo. [[alternative HTML version deleted]]
Hi Rodrigo, it is not easy to anwer your question since you did not provide some data to work with, nor what went wrong with your code. Anyway, as far as I can catch I would try the following library(nlme) df.GD <- groupedData(Y ~ fact_A +fact_B|fact_C, data=DataFrame) lme.1 <-lme(y~fact_A + fact_B, data=GD, random=~1|fact_C) I'm not sure on the syntax for corClasses, but from the book cited below I see some examples like corr=corAR1(0.8, form= ~1|fact_C) Should you move definitely to R, I strongly suggest you to buy and study the following book Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S and S-PLUS", Springer. All the best -- Ottorino-Luca Pantani, Universit? di Firenze Dip. Scienza del Suolo e Nutrizione della Pianta P.zle Cascine 28 50144 Firenze Italia Tel 39 055 3288 202 (348 lab) Fax 39 055 333 273 OLPantani at unifi.it http://www4.unifi.it/dssnp/