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
3
votes
2 answers

How to use Chi-square test for exponential distribution in R

In my dataset I have 15 observations and I want to test whether this distribution can be represented with an exponential distribution with rate=0.54. The variable x is as follows: table(x) x 0 1 2 4 5 7 8 10 2 1 4 2 2 2 1 1 Any…
brock
  • 181
  • 2
  • 10
3
votes
0 answers

Comparing distributions with chi-square in python

I have two types of data lists, historical data and simulated data, that I want to compare with each other to see if they have the same distribution. My code is as follow: import scipy.stats as stats data_hist = [164, 157, 145, 113, 127, 192, 214,…
Pierre
  • 125
  • 1
  • 9
3
votes
1 answer

Retrieving the monte carlo simulation values for chi square test

I am trying to graph the null distribution in a chi square test.In R it is feasible to do monte carlo simulation to get the empirical p value using the code: chisq.test(d,simulate.p.value=TRUE,B=10000) But it does not return the distribution graph.…
Masih
  • 920
  • 2
  • 19
  • 36
3
votes
1 answer

ApacheCommons: Weird results from ChiSquareTest

I am using the Apache Commons lib to calculate the p-value with the ChiSquareTest: I use the method chiSquareTest(double[] expected, long[] observed); But the values I get back don't make sense to me. So I tried numerous ChiSquare Online Calculators…
mnzl
  • 372
  • 3
  • 14
3
votes
2 answers

How to identify the warning generated instances of an operation in a loop?

Based on this solution, I have formulated the below code to perform chisq.test for 33 variables. sapply(Indices,function(i){ chisq.test(data.cleaned[,i],data.cleaned$Out)$p.value }) This code produces 9 warnings, hopefully due to the violation of…
Prradep
  • 5,506
  • 5
  • 43
  • 84
3
votes
1 answer

pwr.chisq.test error in R

I am now trying to estimate the sample size needed for A/B testing of website conversion rate. pwr.chisq.test always gives me error message, when I have small value of conversion rate: # conversion rate for two groups p1 = 0.001 p2 = 0.0011 #…
Peter Pan
  • 65
  • 5
3
votes
1 answer

chi-square distribution R

Trying to fit a chi_square distribution using fitdistr() in R. Documentation on this is here (and not very useful to me): https://stat.ethz.ch/R-manual/R-devel/library/MASS/html/fitdistr.html Question 1: chi_df below has the following output: …
Entropy
  • 133
  • 2
  • 12
3
votes
2 answers

Why 2 outputs of chisq.test are different in R

In following, why are outputs of 2 chisq.test different, when data is really the same: > df1 count position 1 1 11 2 6 12 3 12 13 4 23 14 5 27 15 > df2 count position 1 1 11 2 4 …
rnso
  • 23,686
  • 25
  • 112
  • 234
3
votes
2 answers

How to calculate a Goodness of Fit using Math.net?

Say, I have a die that is 19 times as likely to produce a six as a one, because it has been tampered with. When I throw this die 60 times the expected versus observed frequencies of the six possible outcomes are: 1: 10, 1 2: 10, 10 3: 10, 10 4: 10,…
Dabblernl
  • 15,831
  • 18
  • 96
  • 148
3
votes
1 answer

different p-value for chi-square test in python and R

Being a regular R user, I am learning to do analysis using python, I started with chi-square and did the following: R > chisq.test(matrix(c(10,20,30,40),nrow = 2))$p.value # test1 [1] 0.5040359 > chisq.test(matrix(c(1,2,3,4),nrow =…
lokheart
  • 23,743
  • 39
  • 98
  • 169
3
votes
0 answers

How I know what are the initial values of parameters of the "start" argument in fitdist function of fitdistrplus package?

I'm learning how a fit distributions to my data,I'm using the fitdist function of the fitdistrplus package, but for chi-squared distribution I need to give a named list with the initial values of…
3
votes
1 answer

Finding quantile values for chi squared distribution In MATLAB

I am trying to perform a so called Ljung Box test on different data I have been given. I want to check whether my data is within a 0.95 quantile of the chi squared distribution. This value I can find in tables (such as…
Seb
  • 117
  • 1
  • 6
3
votes
1 answer

Goodness of fit test for power law distribution in R

I have a network for which I fit into a power-law using igraph software: plf = power.law.fit(degree_dist, impelementation = "plfit") The plf variable now holds the following variables: $continuous [1] TRUE $alpha [1] 1.63975 $xmin [1]…
user1830307
3
votes
1 answer

Two-sample chi-squared test in R

I'm really new to R, so please bear with me. I'm using a chi-squared test to compare nucleotide frequencies at a given position, and I counted up the number of A,C,G,T in two different data sets: x1 <- c(272003,310418,201601,237168) x2 <-…
cjolley
  • 441
  • 6
  • 15
3
votes
1 answer

Using loops to do Chi-Square Test in R

I am new to R. I found the following code for doing univariate logistic regression for a set of variables. What i would like to do is run chi square test for a list of variables against the dependent variable, similar to the logistic regression…
dj_stat
  • 35
  • 2
  • 4