[R] Line of Organic Correlation (help with writing function)
stephen sefick
ssefick at gmail.com
Tue Aug 11 16:08:43 CEST 2009
I would like to calculate the line of organic correlation, so that I
can use it for record extension for a stream gauging station. Below
is a description (1) and then my first attempt with R code (2).
Thanks in advance for any help.
Stephen Sefick
The LOC minimizes the sum of the areas of right triangles formed by
horizontal and vertical
lines extending from observations to the fitted line (figure 10.8).
By minimizing errors in both
directions it lies between the two OLS lines on a plot of Y versus X
(see figure 10.7). The slope
of the LOC line equals the geometric mean of the Y on X and X on Y OLS slopes:
b1'' = sqrt(b1*b1') = sign[r] • sy/sx
where b1'' is the slope of the LOC line
Yi = b0'' + sign[r] • sy/sx • Xi
So the correlation coefficient in the equation for OLS slope is
replaced by the algebraic sign
(+ or −) of the correlation coefficient with LOC. The magnitude of
the LOC slope b1'' is
determined solely by the ratio of standard deviations sy/sx.
Performing LOC of X on Y will
give the identical line as does the LOC of Y on X .
I have written this code so far
#line of organic correlation find out how to calculate "slope"
loc <- function(x, y){
cor.xy <- cor(x,y)
sign.xy <- sign(cor.xy)
sd.ratio <- sd(y)/sd(x)
Yi <- "slope" + sign.xy*sd.ratio*x
}
I don't know how to calculate "slope" for the predicted line. Maybe
This is to simple of an approach?
--
Stephen Sefick
Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.
-K. Mullis
More information about the R-help
mailing list