[R] Package 'coin' - How to extract rho

Achim Zeileis Ach|m@Ze||e|@ @end|ng |rom u|bk@@c@@t
Wed Apr 29 13:55:43 CEST 2020


Christine,

thanks for the example. As far as I can see, the "coin" package does not 
explicitly compute Spearman's rho. This is probably also the reason why it 
isn't reported in the test output. Thus, you would have to do this "by 
hand" using cor(..., method = "spearman").

Hope that helps,
Achim


On Wed, 29 Apr 2020, Blume Christine wrote:

> Dear Jim,
>
>
>
> Many thanks for following up on this. Sure, I can provide a sample code. At the end of the code you see that I extract the p-value and the test statistic. However, I cannot find the correlation coefficient rho anywhere in the object “r”.
>
>
>
> Best,
>
> Christine
>
>
>
> if(!require(pacman)) install.packages("pacman")
>
> pacman::p_load(sn, fGarch, coin)
>
>
>
> # Happiness
>
> central_tendency_sim <- 0
>
> dispersion_sim <- 1
>
> skewness_sim <- 1.5
>
>
>
> N_sim <- 10000
>
>
>
> Happiness <- seq(from = 0,
>
>               to = 10,
>
>               length.out = N_sim)
>
>
>
> # City size
>
> central_tendency_sim <- 3
>
> dispersion_sim <- 1
>
> skewness_sim <- 1.5
>
>
>
> Citysize <- seq(from = 1,
>
>                to = 5,
>
>                length.out = N_sim)
>
>
>
> # create dataframe
>
> datastat <- data.frame(Happiness, Citysize)
>
>
>
> # Bootstrapped correlation
>
> r <- spearman_test(Happiness ~ Citysize, data = datastat, distribution = "approximate", alternative = c("two.sided"))
>
> r
>
> pvalue(r)
>
> statistic(r)
>
>
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Jim Lemon <drjimlemon using gmail.com>
> Gesendet: Mittwoch, 29. April 2020 05:53
> An: Blume Christine <christine.blume using sbg.ac.at>
> Cc: r-help using r-project.org
> Betreff: Re: [R] Package 'coin' - How to extract rho
>
>
>
> Hi Christine,
>
> I noticed that your question did not receive a reply. As I don't know exactly what you have tried, it is a bit difficult to suggest a solution. If you are still unable to get this to work, could you provide an example of your present code and data if necessary?
>
>
>
> Jim
>
>
>
> On Mon, Apr 27, 2020 at 3:09 AM Blume Christine <christine.blume using sbg.ac.at<mailto:christine.blume using sbg.ac.at>> wrote:
>
>>
>
>> I am using the 'coin' package to compute bootstrapped correlations. I am able to extract the p-value with confidence intervals as well as the test statistic Z. However, I am unable to find rho, i.e. the correlation coefficient. Can someone help?
>
>>
>
>> Kind regards,
>
>> Christine
>
>>
>
>>
>
>>         [[alternative HTML version deleted]]
>
>>
>
>> ______________________________________________
>
>> R-help using r-project.org<mailto:R-help using r-project.org> mailing list -- To UNSUBSCRIBE and more, see
>
>> 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.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.


More information about the R-help mailing list