[R] chisq.test(): standardized (adjusted) Pearson residuals

Stephen Davies stephen at umw.edu
Sat Aug 20 18:04:56 CEST 2011


> >>> I'm using chisq.test() on a matrix of categorical data, and I see  
> >>> that the
> >>> "residuals" attribute of the returned object will give me the  
> >>> Pearson residuals.
> 
> Actually they are not an attribute in the R sense, but rather a list  
> value.

    Oh. I was just going by:

> attributes(my.chisq.test)
$names
[1] "statistic" "parameter" "p.value"   "method"    "data.name" "observed" 
[7] "expected"  "residuals"

$class
[1] "htest"

    which I interpreted as "this object has 8 attributes, called 'statistic',
'parameter', ..., 'residuals'." Is that not the right terminology?


> >>> That's cool. However, what I'd really like is the standardized  
> >>> (adjusted)
> >>> Pearson residuals, which have a N(0,1) distribution. Is there a  
> >>> way to do that
> >>> in R (other than by me programming it myself?)
> >>
> >> ?scale
> >
> > chisq.test(...)$stdres, more likely.

    "scale" is not what I want. As for "$stdres," that would be wonderful, but
as you can see from the above list of attributes, it's not one of the 8
returned. What am I missing?

- Stephen



More information about the R-help mailing list