[R] Fwd: How to set degrees of freedom in cor.test?
Mike Lawrence
Mike.Lawrence at DAL.CA
Sat Jun 16 13:12:43 CEST 2007
You could calculate the confidence interval of the correlation at
your desired df: http://davidmlane.com/hyperstat/B8544.html
The below code takes as arguments the observed correlation, N, and
alpha, calculates the confidence interval and checks whether this
includes 0.
cor.test2=function(r,n,a=.05){
phi=function(x){
log((1+x)/(1-x))/2
}
inv.phi=function(x){
(exp(2*x)-1)/(exp(2*x)+1)
}
r.prime=phi(r)
err=qnorm(1-(a/2))/sqrt(n-3)
lims=c(inv.phi(r.prime-err),inv.phi(r.prime+err))
sig=ifelse(xor(all(0<lims),all(0>lims)),T,F)
return(sig)
}
> On 14-Jun-07, at 5:40 AM, Florence Dufour wrote:
>
>>
>> Hello,
>>
>> I want to compute a correlation test but I do not want to use the
>> degrees of freedom that are calculated by default but I want to set a
>> particular number of degrees of freedom.
>> I looked in the manual, different other functions but I did not found
>> how to do it
>>
>> Thanks in advance for your answers
>>
>> Yours
>>
>>
>>
>>
>> Florence Dufour
>> PhD Student
>> AZTI Tecnalia - Spain
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-
>> guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> --
> Mike Lawrence
> Graduate Student, Department of Psychology, Dalhousie University
>
> Website: http://myweb.dal.ca/mc973993
> Public calendar: http://icalx.com/public/informavore/Public
>
> "The road to wisdom? Well, it's plain and simple to express:
> Err and err and err again, but less and less and less."
> - Piet Hein
>
--
Mike Lawrence
Graduate Student, Department of Psychology, Dalhousie University
Website: http://myweb.dal.ca/mc973993
Public calendar: http://icalx.com/public/informavore/Public
"The road to wisdom? Well, it's plain and simple to express:
Err and err and err again, but less and less and less."
- Piet Hein
More information about the R-help
mailing list