Questions tagged [chi-squared]

Anything related to chi-squared probability distribution or chi-squared statistical test (typically of distribution, independence, or goodness of fit).

In probability theory and statistics, the chi-squared (X²) distribution with k degrees of freedom is the distribution of a sum of the squares of k independent standard normal random variables. It is one of the most widely used probability distributions in inferential statistics (for example, in hypothesis testing or in construction of confidence intervals).

See also on Wikipedia:

Tag usage

Questions on tag should be about implementation and programming problems, not about the statistical or theoretical properties of the technique. Consider whether your question might be better suited to Cross Validated, the StackExchange site for statistics, machine learning and data analysis.

643 questions
4
votes
3 answers

Chi-Squared Probability Function in C++

The following code of mine computes the confidence interval using Chi-square's 'quantile' and probability function from Boost. I am trying to implement this function as to avoid dependency to Boost. Is there any resource where can I find such…
neversaint
  • 60,904
  • 137
  • 310
  • 477
4
votes
2 answers

How to verify if two text datasets are from different distribution?

I have two text datasets. Each dataset consists of multiple sequences and each sequence can have more than one sentence. How do I measure if both datasets are from same distribution? The purpose is to verify transfer learning from one distribution…
4
votes
2 answers

Apply Chi-Squared Test in R on more than 5 variables and find the p-values

I am new to Chi-Squared Test. I have a database with lots of categorical variable. Sample database with few variables are: I want to apply the CHi-Squared test in R and want to find the p-values of all these categorical variable. Based on that i…
Affan
  • 131
  • 1
  • 2
  • 6
4
votes
1 answer

R: applying Pearson's Chi-square test by two columns

I just started coding in R and I have a question about applying Chi-square test to a dataset by 2 columns at a time. I would like to do a paired analysis (Tumor and Normal sample come from the same patient, so Primary Tumor 1 and Normal Tissue 1…
Kim So Yon
  • 85
  • 7
4
votes
1 answer

Is there a built in Chi square CDF function in C++

I am trying to find a builtin CDF for chi square distribution. Basically, I wish to have a CDF function like pchisq in R, where chisquare(x,p,q) gives you the probability. x is the distribution of the function, p is the dof and q is the…
hao
  • 635
  • 2
  • 8
  • 20
4
votes
1 answer

R Chi Squared Post Hoc Test

I'm new to R (and statistics in general) so apologies in advance for what's probably a very remedial question, but I'd appreciate any help! I'm trying to assess if there's a statistical advantage to starting a motor race in a given lane over…
eod1984
  • 41
  • 1
  • 2
4
votes
1 answer

Using R, apply multiple chi-square contingency table tests to a grouped data frame and add a new column containing the p values of the tests

I have a data frame similar to the example below (which is a small extract of my actual data frame). frequencies <- data.frame(sex=c("female", "female", "male", "male", "female", "female", "male", "male", "female", "female", "male", "male",…
Katie
  • 75
  • 1
  • 5
4
votes
1 answer

Chi-square distribution with c#?

I would like to create an algorithm in C# that implements the chi-square distribution. I I have found a bunch of implementations on the internet but all of them use a lot of framework and I would like somthing simpler for a project at school. How…
marius212
  • 43
  • 1
  • 5
4
votes
1 answer

Get `chisq.test()$p.value` for several groups using `dplyr::group_by()`

I'm trying to conduct a chi square test on several groups within the dplyr frame. The problem is, group_by() %>% summarise() doesn't seem to do trick. Simulated data (same structure as problematic data, but random, so p.values should be…
mpaladino
  • 222
  • 3
  • 10
4
votes
1 answer

Chi-squared goodness of fit test in Python: way too low p-values, but the fitting function is correct

Despite having searched for two day in related questions, I have not really found an answer to this Problem yet... In the following code, I generate n normally distributed random variables, which are then represented in a histogram: import numpy…
Charles M.
  • 83
  • 1
  • 4
4
votes
1 answer

Does R incorrectly compute the chi-squared statistic for 2x2 tables with low cell counts?

I just noticed that for 2 x 2 tables where cells have low frequencies, even with the Yates correction, R seems to be computing chi^2 statistics incorrectly. mat <- matrix(c(3, 2, 14, 10), ncol = 2) chi <- stats::chisq.test(mat) ## Warning…
Ken Benoit
  • 14,454
  • 27
  • 50
4
votes
1 answer

GNUplot fit with only x-errors in version 5?

I'm trying to fit my data using GNUplot. As it happens my data only has x-error bars. I heard version 5 is supposed to allow fitting using x errors only. How can one do this? I tried the following but as you can see I get errors that I cannot figure…
4
votes
2 answers

Run a chi square test with observation and expectation counts and get confidence interval

I am new to chi squared testing and trying to figure out what the 'standard' way of running a chi-squared test and also getting a 95% confidence interval on the difference between success rates in two experiments. My data looks like this: Condition…
helloB
  • 3,472
  • 10
  • 40
  • 87
4
votes
0 answers

How to obtain chi squared value from scipy least_squares function

I am using the least_squares function from scipy http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.least_squares.html to fit a model to some data that I took, and obtain a value for the parameters in the model. I would like to also…
PiccolMan
  • 4,854
  • 12
  • 35
  • 53
4
votes
3 answers

Is there a Pair-Wise PostHoc Comparisons for the Chi-Square Test in R?

I am wondering if there exists in R a package/function to perform the: "Post Hoc Pair-Wise Comparisons for the Chi-Square Test of Homogeneity of Proportions" (or an equivalent of it) Which is described here:…
Tal Galili
  • 24,605
  • 44
  • 129
  • 187
1 2
3
42 43