[R] Package 'coin' - How to extract rho
Blume Christine
chr|@t|ne@b|ume @end|ng |rom @bg@@c@@t
Wed Apr 29 14:31:07 CEST 2020
Dear Achim,
Many thanks indeed. Yes, I had thought about this too and, fortunately, the bootstrapping confirms the results from the "normal" test. However, I was wondering whether it is mathematically acceptable to report the pvals from bootstrapping, but non-bootstrapped correlation coefficients. Does someone have an opinion on this?
Best,
Christine
-----Ursprüngliche Nachricht-----
Von: Achim Zeileis <Achim.Zeileis using uibk.ac.at>
Gesendet: Mittwoch, 29. April 2020 13:56
An: Blume Christine <christine.blume using sbg.ac.at>
Cc: Jim Lemon <drjimlemon using gmail.com>; Torsten.Hothorn using uzh.ch; r-help using r-project.org
Betreff: Re: [R] Package 'coin' - How to extract rho
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