Skip to content

Fit unequal variance model in R

9 messages · Feng, Jingyu, Dieter Menne, Feng Jingyu

#
Feng, Jingyu wrote:
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
2 days later
#
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")
summary(lm3)
Generalized least squares fit by maximum likelihood
  Model: GSI ~ treatment 
  Data: z 
       AIC      BIC    logLik
  9.174574 12.71483 0.4127128


Coefficients:
                   Value Std.Error   t-value p-value
(Intercept)    1.0174923 0.1374462  7.402839  0.0000
treatmentHigh  0.7429293 0.1943783  3.822079  0.0028
treatmentLow  -0.0146910 0.1943783 -0.075579  0.9411
treatmentMid   0.3869267 0.2099526  1.842924  0.0924

 Correlation: 
              (Intr) trtmnH trtmnL
treatmentHigh -0.707              
treatmentLow  -0.707  0.500       
treatmentMid  -0.655  0.463  0.463

Standardized residuals:
       Min         Q1        Med         Q3        Max 
-1.9580366 -0.7219450 -0.1989222  0.9096203  1.8319336 

Residual standard error: 0.2354039 
Degrees of freedom: 15 total; 11 residual
Dieter Menne wrote:

  
    
#
Feng Jingyu wrote:
try

weights = varIdent(form~1|treatment)

See the example in library/nlme/scripts/ch05.r ,fm1Orth.gls

Dieter
#
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:
To conserve you sanity, don't try it. They will be different.

Dieter
#
Hi For my purpose, I need to match variance estimates for each group from R
and SAS. They do match now. I notice there are still some difference between
those two. For example the standard errors of coeffieicints are different,
but I don't care those.
Dieter Menne wrote:

  
    
#
Yes, I am considering I am a lucky man because you answered my question. Have
a great weekend!
Dieter Menne wrote: