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

Can this for-loop be vectorized

I implemented a chi-square test in R using a for-loop in order to calculate the test statistic for every cell. However, I was wondering whether this can be optimized. And is the chi=square in R working as my code? eval_preds <- function(df,…
hyhno01
  • 177
  • 8
-2
votes
2 answers

Chi-Square test for groups of unequal size

I'd like to apply chi-square test scipy.stats.chisquare. And the total number of observations is different in my groups. import pandas as pd data={'expected':[20,13,18,21,21,29,45,37,35,32,53,38,25,21,50,62], …
Anton
  • 109
  • 9
-2
votes
1 answer

pyspark p values and chisquaretest correlations

+----------+---------------+--------------------+--------------+-------+-----------+-----------+-----------+-----------+-----------+-----------+------------+------------+-------------+-------------+-------------+-------------+-------------+----------…
Kor
  • 63
  • 1
  • 8
-2
votes
1 answer

How to fix incorrect chi2pdf results in MATLAB R2019A

I am working with MATLAB R2019A (Slightly out of date, I know) on Linux Mint 19.1. For the task I am trying to perform, I need the chi2pdf function, but when I tried to use it, it gave incorrect results. Just to test it, I tried the following, and…
-2
votes
1 answer

MCMC(Markove Chain MOnteCarlo) in python

Could anyone help me about MCMC in python? I want to fit a model with 5 or 6 parameters using this tool(MCMC). I have searched a lot but there are no learning ways to check how to do that! Please some help I use the chi square equation but for 5…
Bob
  • 39
  • 1
  • 10
-2
votes
1 answer

Fisher exact test takes long in R, how the improve speed?

My table has 770,000 rows and what I did is: mydata <- dbGetQuery(mydb, "select * from table") mydata$pvalue <- apply(as.matrix(mydata[, c(3,5,4,6)]), 1, function(x) fisher.test(matrix(x, nrow=2))$p.value) to get pvalues. But it takes so…
dPdms
  • 173
  • 2
  • 14
-2
votes
2 answers

SQL Query for Chi-SQUARE TEST

I am trying to find the CHI-SQUARE TEST on the following set of data in the table. I am trying my this Query to find the CHI-SQUARE TEST: SELECT sessionnumber, sessioncount, timespent, (dim1.cnt * dim2.cnt * dim3.cnt)/(dimall.cnt*dimall.cnt) as…
Tech Nerd
  • 822
  • 1
  • 13
  • 39
-3
votes
1 answer

Unexplained results with chi-square test (R)

I have some trouble using the chisq.test command in R : I got different and weird results according to how I use the data. Let's say I have the following table named t: > t data1 data2 data3 data4 data5 1487 3301 2983 …
Micawber
  • 707
  • 1
  • 5
  • 19
-3
votes
1 answer

I don't know how to use boost and although my teacher did provide the code I am getting an error

I don't know if I am implementing this correctly. I created a function called boosted that returns the float for the given value but I am getting this error. terminate called after throwing an instance of …
-3
votes
1 answer

What does the p value represent in the scipy.stats chisquare function?

I am using the scipy.stats.chisquare function, as explained on https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chisquare.html I understand that, in general, the p-value demonstrates how well the data supports the null hypothesis. A…
PiccolMan
  • 4,854
  • 12
  • 35
  • 53
-4
votes
1 answer

Dependency matrix

I need to build a dependency matrix with all the 91 variables of my data-set. I tried to use some codes, but I didn't succeed. Here you are part of the important codes: p<- length(dati) chisquare <- matrix(dati, nrow=(p-1), ncol=p) It should…
Andrea
  • 41
  • 4
-5
votes
1 answer

R: chisq.test at 99%

Is there a way to set chi sq test confidence from 95% to 99%? The base function chisq.test() don't complains this function... Edit: I don't ask for p-values. My question is about confidence risk . The alpha risk (confidence) of chisq test is by…
Kaervas
  • 103
  • 2
  • 16
-14
votes
1 answer

Transform the form of the function's result and get the maximum value

library(CHAID) data("USvote") functionB <- function(z,y) { for (i in 1:length(table(z[,y]))) { n<-paste(names(table(z[,y]))[i]) V = paste('vote3') Formula <- as.formula(paste(y," ~ ", paste(V))) k = aggregate(Formula,data =…
Zhe Zhang
  • 15
  • 3
1 2 3
42
43