[R] Ordinary Least Products regression in R

Christopher Tong stavka_ctong at q.com
Thu Jul 28 06:00:10 CEST 2011


Dear Bill,

For bivariate data, ordinary least product regression is equivalent to 
geometric mean regression, or what Freedman/Pisani/Purves call the “SD Line” 
(line passing through the centroid of the data, whose slope's magnitude is 
the ratio of the standard deviations of the variables, and sign of the slope 
is equal to the sign of the covariance).  It is also the first standardized 
principal component.

I think this will work for bivariate data.  (It first removes any data pair 
with at least one NA.)

gmr <- function(x,y)
{
    if (is.numeric(x) & is.numeric(y) & length(x) == length(y)) {
    na.idx <- is.na(x) | is.na(y)
    x <- x[!na.idx]
    y <- y[!na.idx]

    slope <- sign(cov(x,y))*sd(y)/sd(x)
    int <- mean(y) - slope*mean(x)
    } else {
        int <- NA
        slope <- NA
        print("Wrong data type")
    }

    list(int=int,slope=slope)
}


/* References: */
Barker, Soh, & Evans, 1988:  Biometrics, 44:  279-281.
Draper & Yang, 1997:  Computational Statistics and Data Analysis, 23: 
355-372.
Freedman, Pisani & Purves, 2007:  Statistics, 4th ed.  (Norton, New York).
Kruskal, 1953:  Biometrics, 9:  47-58.
Ludbrook, 1997:  Clinical and Experimental Pharmacology and Physiology, 24: 
193-203.
Tofallis, 2003:  Annals of Operations Research, 124:  69-79.

------------------------------

> Date: Tue, 26 Jul 2011 22:45:37 -0700 (PDT)
> From: Bill Hyman <billhyman1 at yahoo.com>
> To: "R-help at r-project.org" <R-help at r-project.org>
> Subject: [R] Ordinary Least Products regression in R
> Message-ID: 
> <1311745537.86654.YahooMailNeo at web126116.mail.ne1.yahoo.com>
> Content-Type: text/plain; charset=us-ascii
>
> Dear all,
>
> Does any one know if any R package or function can do Ordinary Least 
> Products regression? Many thanks!
>
> Bill



More information about the R-help mailing list