I'am trying to develop some code if R, which would correspond to what I did in SAS. The data look like: Treatment Replicate group1 GSI Control A 1 0.81301 Control B 1 1.06061 Control C 1 1.26350 Control D 1 0.93284 Low A 2 0.79359 Low B 2 0.89111 Low C 2 1.03485 Low D 2 1.29166 Mid A 3 1.26900 Mid B 3 . Mid C 3 1.58666 Mid D 3 1.35759 High A 4 2.02680 High B 4 1.52372 High C 4 2.19167 High D 4 1.29949 The SAS code is: proc mixed data=data_name order=data method=ml; *scoring=10; classes group1; model GSI=group1/residual influence solution; repeated /group=group1; run; Basically, I need different variance for each treatment group. I want to do the similar thing in R. Here is what I get so far: lm1<-lme(response~treatment,data=o,random=~1|as.factor(dummy),weights=varIdent(form=~1|treatment),method="ML") There should no random term in the model. However If I don't specify one, lme won't work, so I made a dummy variable, which equals to 1 for every observation. If anyone could help, it will be greatly appreciated. Thanks, Jingyu [[alternative HTML version deleted]]
Feng, Jingyu wrote:> > I'am trying to develop some code if R, which would correspond to what I > did in SAS. > The data look like: > > Treatment Replicate group1 GSI > > .. > The SAS code is: > proc mixed data=data_name order=data method=ml; *scoring=10; > classes group1; > model GSI=group1/residual influence solution; > repeated /group=group1; > > run; > > Basically, I need different variance for each treatment group. I want to > do the similar thing in R. > > Here is what I get so far: > lm1<-lme(response~treatment,data=o,random=~1|as.factor(dummy),weights=varIdent(form=~1|treatment),method="ML") > > There should no random term in the model. However If I don't specify one, > lme won't work, so I made a dummy variable, which equals to 1 for every > observation. > >The much underused (quote Frank Harrell) gls in package nlme should do that. Quote PB (p250): It can be viewed as an lme function without the random argument. Dieter -- View this message in context: http://www.nabble.com/Fit-unequal-variance-model-in-R-tp22829549p22830566.html Sent from the R help mailing list archive at Nabble.com.
Thanks a lot. The problem is solved. It took me a while to understand the output from the R. With little calculation, I am able to match results from R to SAS. Dieter Menne wrote:> > > Feng Jingyu wrote: >> >> I used gls and it still does not provide me different estimates of >> variance for each treatment group. Did I do anything wrong? >> >> lm3<-gls(GSI~treatment,data=z,weights=varIdent(form=~treatment),method="ML") >> > > try > > weights = varIdent(form~1|treatment) > > See the example in library/nlme/scripts/ch05.r ,fm1Orth.gls > > Dieter > > > > >-- View this message in context: http://www.nabble.com/Fit-unequal-variance-model-in-R-tp22829549p22873995.html Sent from the R help mailing list archive at Nabble.com.
Yes, I am considering I am a lucky man because you answered my question. Have a great weekend! Dieter Menne wrote:> > > Feng Jingyu wrote: >> >> Hi For my purpose, I need to match variance estimates for each group from >> R and SAS. They do match now. >> > Consider yourself a lucky man! > > Dieter > > >-- View this message in context: http://www.nabble.com/Fit-unequal-variance-model-in-R-tp22829549p22877276.html Sent from the R help mailing list archive at Nabble.com.