[R] R correlations.

Michaell Taylor pols1oh at bestweb.net
Thu Jun 6 22:33:03 CEST 2002



Sounds like you have unreliable data and the reliability varies.  This 
frequently leads me to simulate (easier than actually thinking eh?).  

I would be tempted to calculate random draws around the confidence intervals 
for each datapoint, calculate the correlation, repeat. - thus gaining a 
distribution (i.e. confidence interval) around the correlation.

Your data looks like:
var1 <- FIRST VAR
var2 <- SECOND VAR
N1 <- # of obs in var1
N2 <- # of obs in var2

# calculation of standard error of proportions
ci1 <- var18(1-var1)/(N1)^.5   <<<---- Caution, my confidence interval on 			
							proportions comes with no guarantees.
							It has been too long.
ci2 <- var2*(1-var2)/(N2)^.5
l1 <- length(var1)
l2 <- length(var2)

distribution.of.corrs _ numeric()
for (N in 1:1000) {
	x <- var1+(rnorm(l1)*ci1)  <<- produces a random draw within sample interval
	y <- var2+(rnorm(l2)*c2)
	distribution.of.corrs _ c(distribution.of.corrs,cor(x,y))
}
summary(distribution.of.corrs)
plot(distribution.of.corrs)    # because pictures are always nice.


Of course, more thoughtful list members probably have a better idea.

Michaell

On Thursday 06 June 2002 02:39 pm, Russell Zaretzki wrote:
> Hi, anybody have any ideas on this ?
>
>
> I have two sequences of proportions.  Due to
> conventions in my field, I need to produce a linear
> correlation between the two.  Each sequence of
> proportions are based upon differing numbers of
> observations (although within a sequence the number of
> observations may not fluctuate too much) so it may be
> necessary/advisable to variance stabilize. Is their a
> best way to go about doing this in R?
>
> I am tempted to do something like the following:
>
> Use the logistic transformation on each proportion.
> Next do weighted least squares.  Finally, adjust the
> beta coef by multiplying by sqrt(Sxx/Syy). However,
> this doesn't take into account the variance in the
> independant variable.
>
> Maybe its better too work with counts of successes
> instead of proportions?
>
> Is their a better way and how do I do it best with R?
>
> Thanks in advance for any help.
>
>
> __________________________________________________
>
> Yahoo! - Official partner of 2002 FIFA World Cup
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
>.-.- r-help mailing list -- Read
> http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or
> "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>._._

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list