s-news
[Top] [All Lists]

Re: Is Theil's test available in S+?

To: Tim.Keighley@csiro.au
Subject: Re: Is Theil's test available in S+?
From: Sven.Knudsen@adeptscience.dk
Date: Mon, 24 Jun 2002 08:51:00 +0200
Cc: s-news@lists.biostat.wustl.edu
Theil's test is not standard in S-Plus. Here is what i found on  S-NEWS:

      To: "Ray Haraf" <rayharaf@rogers.com>, "Snews \(E-mail\)" <
      s-news@lists.biostat.wustl.edu>
      Subject: Re: Theil's U
      From: "Daniel Rie" <rie@world.std.com>
      Date: Thu, 7 Feb 2002 21:13:45 -0500
      References: <
      00fc01c1b02c$7e63bdc0$cf867018@bloor.phub.net.cable.rogers.com>
      Sender: s-news-owner@lists.biostat.wustl.edu
                                                                                
                                                                      
 >There appears to be some confusion in your post.  Theil's U is does not use 
 >X*log(X) (although entropy measures do).  One of the pleasures of S is  
 that you can implement simple measures and expressions directly if you >want 
them.  Often it doesn't even take multiple posts to s-news to get       
 results.  There really is no known substitute for a little diligence in 
working through problems and reading some documentation.                     
                                                                                
                                                                      
 >If Theil's U is really what your are after, you might try writing a function 
 >such as                                                                
                                                                                
                                                                      
 TheilU<-function(xvec, yvec, na.rm = F)                                        
                                                                      
 {                                                                              
                                                                      
  if(length(xvec) != length(yvec))                                              
                                                                      
   stop("input vectors to TheilU must be of same length")                       
                                                                      
  rmxs <- function(dvec)                                                        
                                                                      
  {                                                                             
                                                                      
   sqrt(sum((dvec - mean(dvec)) * (dvec - mean(dvec)))/length(dvec))            
                                                                      
  }                                                                             
                                                                      
  if(na.rm == T)                                                                
                                                                      
   OK <- (!is.na(xvec)) & (!is.na(yvec))                                        
                                                                      
  else OK <- 1:length(xvec)                                                     
                                                                      
  rmxs(xvec[OK] - yvec[OK])/(rmxs(xvec[OK]) + rmxs(yvec[OK]))                   
                                                                      
 }                                                                              
                                                                      
 (Make sure to check the actual definition of U before you use this. I'm not 
sure that the means enter the calculation.)                              
                                                                                
                                                                      
 If what you really want is a measure of cross-entropy, you could write a 
corresponding function to do that calculation.  (However, the cross-entropy 
 calculation does require some strategy for dealing with the zero probability 
cases that is not covered by X*log(X) limits.)                          
                                                                                
                                                                      
 Dan Rie                                                                        
                                                                      
  ----- Original Message -----                                                  
                                                                      
  From: Ray Haraf                                                               
                                                                      
  To: Snews (E-mail)                                                            
                                                                      
  Sent: Thursday, February 07, 2002 6:09 PM                                     
                                                                      
  Subject: [S] Theil's U                                                        
                                                                      
                                                                                
                                                                      
  Dear S+ users,                                                                
                                                                      
                                                                                
                                                                      
  For a two-way table between X and Y, Theil's U (uncertainty coefficient) is 
the proportional reduction in entropy of X that results from knowing    
  the value Y. U is one of statistics produced for each two-way table by PROC 
FREQ of SAS. Is there a S+ procedure (similar to chisq.test()) to       
  calculate U?                                                                  
                                                                      
                                                                                
                                                                      
  Thanks in advance,                                                            
                                                                      
                                                                                
                                                                      
  Ray.                                                                          
                                                                      
                                                                                
                                                                      






Best Regards
Adept Scientific

Sven J. Knudsen

*********************************************************************
Solutions for Technical Computing

Adept Scientific Aps             Tel: ; +45 48 25 17 77
Nordre Jernbanevej 13C       Fax: ; +45 48 24 08 47
DK-3400  Hillerød

Web:  http://www.adeptscientific.dk
WebStore:  http://www.adeptstore.dk
********************************************************************


|---------+------------------------------------>
|         |           Tim.Keighley@csiro.au    |
|         |           Sent by:                 |
|         |           s-news-owner@lists.biosta|
|         |           t.wustl.edu              |
|         |                                    |
|         |                                    |
|         |           24-06-2002 06:48         |
|         |                                    |
|---------+------------------------------------>
  
>---------------------------------------------------------------------------------------------------------------------------------------------|
  |                                                                             
                                                                |
  |       To:       s-news@lists.biostat.wustl.edu                              
                                                                |
  |       cc:                                                                   
                                                                |
  |       Subject:  [S] Is Theil's test available in S+?                        
                                                                |
  
>---------------------------------------------------------------------------------------------------------------------------------------------|




Greetings s-news hounds,

I was wondering if Theil's test is available in S+. I am asking this on
behalf of someone else, so I don't know exactly what is supposed to do, but
I think it is different from Theil's U coefficient which has been mentioned
on this list before. I believe it is used and recommended by the US EPA in
their trend reports. Below are some references. I have code for SAS, but
obviously it would be preferable to use S+.

Cheers,
Tim Keighley



Hollander, M. and Wolf, D.A. 1973, Nonparametric Statistical Methods, John
Wiley & Sons, New York, pp.200-206.

Kendall, M.G. and Gibbons, J.D. 1990, Rank Correlation Methods, 5th Ed.,
Oxford University Press, New York, pp.90-92.

Theil, H. 1950a, A Rank-Invariant Method of Linear and Polynomial
Regression
Analysis, I. Proc. Kon. Ned. Akad. V. Wentesh. A., 53, 386-92.

Theil, H. 1950a, A Rank-Invariant Method of Linear and Polynomial
Regression
Analysis, II. Proc. Kon. Ned. Akad. V. Wentesh. A., 53, 521-5.

Theil, H. 1950a, A Rank-Invariant Method of Linear and Polynomial
Regression
Analysis, III. Proc. Kon. Ned. Akad. V. Wentesh. A., 53, 1397-412.

_____________________________________________________________________
Tim Keighley
CSIRO Mathematical and Information Sciences      Building E6B
Locked Bag 17, North Ryde, NSW 1670, Australia   Macquarie University
Phone: +61 2 9325 3144  Fax: +61 2 9325 3200     Sydney, Australia
E-mail: Tim.Keighley@csiro.au
WWW: http://www.cmis.csiro.au/Tim.Keighley
_____________________________________________________________________

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news





<Prev in Thread] Current Thread [Next in Thread>