Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6629413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:15:23+00:00 2026-05-25T22:15:23+00:00

I am getting some inconsistant results when using the weights argument in the coin

  • 0

I am getting some inconsistant results when using the weights argument in the coin package. In particular for the kruskal_test and spearman_test functions.

With regular data everything works fine and agrees with kruskal.test in the stats package:

> x <- xtabs( ~gear + vs,data=mtcars)
> df <- as.data.frame.table(x)
> kruskal_test(gear ~ as.factor(vs),data=mtcars)

    Asymptotic Kruskal-Wallis Test

data:  gear by as.factor(vs) (0, 1) 
chi-squared = 2.4768, df = 1, p-value = 0.1155
> kruskal.test(gear ~ as.factor(vs),data=mtcars)

    Kruskal-Wallis rank sum test

data:  gear by as.factor(vs) 
Kruskal-Wallis chi-squared = 2.4768, df = 1, p-value = 0.1155

But, when the same data is fed to kruskal_test with frequency weights, I get an incorrect result.

> kruskal_test(as.numeric(df[[1]]) ~ df[[2]],
+ weights=~as.integer(df[[3]]))

    Asymptotic Kruskal-Wallis Test

data:  as.numeric(df[[1]]) by df[[2]] (0, 1) 
chi-squared = 1.3158, df = 1, p-value = 0.2513

Is there a problem with the way I am setting up this function call?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:15:24+00:00Added an answer on May 25, 2026 at 10:15 pm

    This was indeed a bug. Thorsten responded that the rank transformation was not taking into account the weights. The following code demonstrates the non-rank version of the test yielding identical results:

    > oneway_test(as.integer(gear) ~ vs, data = df, weights  = ~ Freq)
    
        Asymptotic 2-Sample Permutation Test
    
    data:  as.integer(gear) by vs (0, 1) 
    Z = -1.1471, p-value = 0.2513
    alternative hypothesis: true mu is not equal to 0 
    

    Hopefully this will get fixed in the future.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting some strange, intermittent, data aborts (< 5% of the time) in some
I'm getting some confusing results around myCustom.ashx handler. If i visit the handler via
I am getting some junk data returned from a ToString() call on a DateTime
In getting some random spanish newspaper's index I don't get the diacriticals properly using
We are getting some unexpected results randomly from some servers when trying to open
I'm getting some html data from remote server and before displaying it in the
Having some problems with getting some ajax script to work. Using this as the
I'm getting some strange results for a script I'm writing to for a typewriter
I am getting some weird results while trying to pass a complex JSON object
I am getting some errors thrown in my code when I open a Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.