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
0 answers

rules to apply monte carlo simulation of p-values for chi square test

I'm sorry if it is not the right place, but i did not find the answer elsewhere. I'd like to know if I understood well the use of monte carlo simulation for the use of chisq.test(). I have a qualitative variable which has 128 levels/classes. My…
jtextori
  • 239
  • 2
  • 7
3
votes
6 answers

Call R from JAVA to get Chi-squared statistic and p-value

I have two 4*4 matrices in JAVA, where one matrix holds observed counts and the other expected counts. I need an automated way to calculate the p-value from the chi-square statistic between these two matrices; however, JAVA has no such function as…
user1830307
3
votes
1 answer

chi square test in R when your data is a list of observations

Is it possible to calculate chi squared in R when your data is in the form of a list of observations? What I mean is, it is simple to get chi squared if you know the cross. For instance, if you have a survey and you ask for gender and a true-false…
user2047228
  • 73
  • 1
  • 3
  • 10
2
votes
0 answers

Significance testing for multiple levels of groupings using counts/proportions with missing values

With an example data set that looks like data.frame( Treatment = c("A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B"), Patient =…
Julian
  • 21
  • 3
2
votes
1 answer

Different chi-squared test values in R and online calculators

I'm calculating chi-squared goodness of fit test. There are four vegetation types (A–D), each occupies a given % of the total study area, and in each vegetation a total number of specimens was calculated. The question is whether a distribution of a…
2
votes
1 answer

Return a string vector instead of integer vector when combining factors

I have a test data test_data <- as.data.frame(list( Drugs = c(1, 2, 2, 2, 1, 2, 2, 3, 2, 2, 2, 2, 2, 2, 1, 3, 2, 1, 1, 2, 3, 3, 2, 3, 1, 2, 2, 2, 2, 2, 3, 3, 2, 2, 2, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 3, 1, 3, 1, 1, 2, 1, 2,…
Lara
  • 129
  • 7
2
votes
1 answer

Chi square approximation may be incorrect

I have a dataset that looks like this: Dataset > dput(THSWP1_23) structure(list(`Town District` = c(1, 2, 3, 4, 5, 6, 7, 8, 9), `health score 1` = c(50, 236, 215, 277, 261, 333, 414, 385, 358), `Health score 2 and 3` = c(51, 238, 218, 281, 266,…
2
votes
1 answer

How to have a list iterate the name of a variable as it runs through a loop

thank you for your time! I am trying to run a chi-squared test through each of the variables in my dataset, and I am executing it with a loop that runs through a list. However, I am trying to figure out the syntax to make the loop print the variable…
lorrsto
  • 23
  • 3
2
votes
1 answer

Chi square tests for multiple columns in R

Here,I made data as follows: data<-data.frame(alzheimer=c(1,1,0,1,0,0,1,0,0,0), asthma=c(1,1,0,0,1,1,1,1,0,0), points=c(0,1,3,5,3,2,1,2,1,5), sex=c(1,1,0,0,0,0,1,1,1,0)) I want to know whether sex…
Lee
  • 369
  • 1
  • 6
2
votes
2 answers

Chi-square tests for different groups in a R dataframe

I have a huge dataframe with the following basic structure: data <- data.frame(species = factor(c(rep("species1", 4), rep("species2", 4), rep("species3", 4))), trap = c(rep(c("A","B","C","D"), 3)), …
2
votes
3 answers

I want to create a 2X2 table for Chisq test from multiple levels categorical dataset

I have a dataset of race and outcome either (Y,N) I want to tabulate a 2X2 table to run a chisq test for each race. Asian 584 24 Black 1721 56 Hispanic 2400 90 White 8164 289 Once I create a table 2X2 so the first row will…
CodeRCodeP
  • 73
  • 5
2
votes
1 answer

How to perform chi-squared test in R in my dataset?

I have the following dataset on I would like to perform chi-squared test, since I am curious whether is there any significant difference between the number of males and females with different genotypes. I've tried several solution (I'm not writing…
selender14
  • 21
  • 1
2
votes
2 answers

Fix a column in for loop while doing Chi-square test

I want to perform chi-square test of independence on the following dataset. The dataset consists of four categorical variables. The test is performed on two variables at a time with variable V4 fixed. Essentially, I want to perform chi-square for 3…
vp_050
  • 583
  • 2
  • 4
  • 16
2
votes
0 answers

How to loop through every column pair

I have an excel file that is 199 x 15 (has 15 columns and 199 rows). My job is to compute the stats for every pairs of 15 columns. Basically column (1,2), (1,3), (1,4), ... (14,15)... and so on for all pairs.I have to do it for each of the 105…
hershey10
  • 77
  • 4
2
votes
1 answer

chi square table in mathematica

I wanted to calculate the probability associated to a given chi-squared value for any given number of degrees of freedom k. I could easily come up with this code: P[chisquare_, k_] = Manipulate[NIntegrate[PDF[ChiSquareDistribution[k], x], {x,…
saimon
  • 47
  • 5