#!/bin/sh
# to extract, remove the header and type "sh filename"
if `test ! -s ./summary`
then
echo "writing ./summary"
cat > ./summary << '\End\Of\Shar\'
rg-corr This is a set of four fumctions in SHAR file that computes
the (robust) Greatest Deviation Correlation Coefficient that is useful
on normal and erratic data. Contr. by ma_rg@selway.umt.edu
\End\Of\Shar\
else
echo "will not over write ./summary"
fi
if `test ! -s ./README`
then
echo "writing ./README"
cat > ./README << '\End\Of\Shar\'
rg-corr This is a set of four S functions in a SHAR file that computs
the (robust) Greatest Deviation Correlation Coefficient that is useful
on normal and erratic data. COntr. by ma_rg@selway.umt.edu
The Greatest Deviation Correlation Coefficient (r=corr, g=greatest, in
rg) was defined in JASA June 1987 pages 656-666. Four S functions are
needed to compute it. All correlations studies should include an
evaluation by a robust correlation and rg fills that role.
(1) rgave(x,y), x and y the paired data of observations, and ave means
that rg is computed as (rgpos+rgneg)/2.
(2) rgpos is used by rgave when ties are arranged to compute a maximum
possible rg.
(3) rgneg is used by rgave when ties are arranged to compute a minimum
possible rg.
(4) rg contains the basic algorithm to compute rg from the ranked data.
It is used by rgpos and rgneg.
If no ties are present in the x-y data then rgneg and rgpos will give
the same result. The transformation r=sin(pi*rg/2) will give a value
that should compare to Pearson's (rp,say) if the data is "good". If
there is a disagreement then the data has one or more points that
could be considered as outliers.
If rp>>r most of data does not show large correlation but a few
outliers give a false high rp.
If r>=rp, then most of data show good correlation but a few outliers
are counter to the most of the data.
This software can be used for freely for non-commercial purpose only.
It can be redistributed to non-commercial users. The author would
appreciate any examples of use that helped them draw better conclusions
about their data. Simple linear regression can be done with rg by
an interative technique. Currently, it must be done manually. If
contacted the author will send you a prepublication copy of an article
describing the technique. It is quite general and can be used with other
nonparametric correlation coefficient, and only takes a few minutes to
get a reasonably good approximation.
Rudy Gideon, Department of Mathematical Sciences, University of Montana,
Missoula, MT 59812. ma_rg@selway.umt.edu
\End\Of\Shar\
else
echo "will not over write ./README"
fi
if `test ! -s ./rgave`
then
echo "writing ./rgave"
cat > ./rgave << '\End\Of\Shar\'
function(x, y)
{
(rgpos(x, y) + rgneg(x, y))/2
}
\End\Of\Shar\
else
echo "will not over write ./rgave"
fi
if `test ! -s ./rgpos`
then
echo "writing ./rgpos"
cat > ./rgpos << '\End\Of\Shar\'
function(x, y)
{
xt <- x[order(y, x)] # x ordered by y with y ties ordered by x
rky <- 1:len(y)
rky <- rky[order(xt, rky)] # ranks of y ordered by x
rg(rky)
}
\End\Of\Shar\
else
echo "will not over write ./rgpos"
fi
if `test ! -s ./rgneg`
then
echo "writing ./rgneg"
cat > ./rgneg << '\End\Of\Shar\'
function(x, y)
{
xrr <- len(x) + 1 - rank(x) #reverse ranks on the x
xt <- x[order(y, xrr)] #x ordered by y with y ties ordered by rev(x)
rky <- 1:len(y)
yrr <- len(y) + 1 - rky #reverse ranks on y
rky <- rky[order(xt, yrr)] #ranks of y ordered by x with y ties
rg(rky) #ordered by rev(y)
}
\End\Of\Shar\
else
echo "will not over write ./rgneg"
fi
if `test ! -s ./rg`
then
echo "writing ./rg"
cat > ./rg << '\End\Of\Shar\'
function(rky)
{
dy <- NULL
for(i in 1:len(rky))
dy <- c(dy, sum(rky[1:i] - i > 0))
mdy <- max(dy)
ryr <- len(rky) + 1 - rky
dyn <- NULL
for(i in 1:len(rky))
dyn <- c(dyn, sum(ryr[1:i] - i > 0))
mdyr <- max(dyn)
corrg <- (mdyr - mdy)/(len(rky) %/% 2) #print(corrg)
corrg
}
\End\Of\Shar\
else
echo "will not over write ./rg"
fi
echo "Finished archive 1 of 1"
exit