# Class variable, table and chisq.test functions question

1.-I am calculating the probability of default with Chi-squared test Null Hypothesis [chisq.test() function].

2.- My dependent variable is "default" that has two values: 1 (applicant defaulted on loan) and 0 (applicant paid loan).

3.- For predicting the probability of student (an informative variable) to be defaulted [chisq.test(table(student,default)] which value should "default" present for applicant defaulted on loan: 1 (True) or 0 (False)?

Thanks in advance. Sorry for being unclear.

• It's best not to assume that everyone uses the same software as you. That said, chi-square tests (indeed statistical analyses generally) neither know nor care what categories mean to you or how they are labelled. If that doesn't help, you may need to give much more detail. – Nick Cox Feb 26 '18 at 17:40
• How does a chi-squared test "predict" the value of a variable? – whuber Feb 26 '18 at 17:53
• Amplifying @whuber 's comment, it seems like you don't want chi-square here. You probably want logistic regression. Also, the chi-square result is insensitive to how the categories are labeled and does not "default" to anything. – Peter Flom Feb 27 '18 at 12:32

## 1 Answer

Answers to each part of your question:

I am calculating the probability of default with Chi-squared test Null Hypothesis [chisq.test() function].

No, you aren't. That's not what a chi square test does. You can estimated the population proportion with the sample proportion and get confidence intervals around that proportion, but this isn't a chi-square problem.

2.- My dependent variable is "default" that has two values: 1 (applicant defaulted on loan) and 0 (applicant paid loan).

Chi-square tests do not have a dependent variable. They are tests of association. With a dependent variable, you want regression. Since your dependent variable is dichotomous (default/not) you want logistic regression. You can test whatever independent variables you want (e.g. whether the person is a student or not, which you mention below).

3.- For predicting the probability of student (an informative variable) to be defaulted [chisq.test(table(student,default)] which value should "default" present for applicant defaulted on loan: 1 (True) or 0 (False)?

It's irrelevant which is the default, one choice or the other will make the output a little easier to read, but they are equivalent.