# Formulating a hypothesis test about dependence

I have a data set of 91 variables. It is related to a qualitative analysis I made to analyse a few phenomena. For this reason, the questions are grouped in 10 clusters, since they express different aspects of the analysis.

I made a subset using the following R command:

example1<- subset(data, select=c("a1", "a2", "a14", "a21"))


then I made a dependence matrix to check the dependence among the single variables in each cluster:

p1 <- stat1 <- diag(ncol(example1))

colnames(p1) <- rownames(p1) <- colnames(exemple1)

colnames(stat1) <- rownames(stat1) <- colnames(example1)
rn <- rownames(p1)
cn <- colnames(p1)

###loop for the p-values
for(i in 1:ncol(example1)){
for(j in 1:ncol(example1)){
a <- example1[, rn[i]]
b <- example1[, cn[j]]
r <- chisq.test(a,b)$p.value p1[i, j] <- r } } ###loop for the statistic for(i in 1:ncol(example1)){ for(j in 1:ncol(example1)){ a <- example1[, rn[i]] b <- example1[, cn[j]] r <- chisq.test(a,b)$statistic
stat1[i, j] <- r
}
}

### placing the p-values in the upper diagonal of stat
stat1[upper.tri(stat1)] <- p1[upper.tri(p1)]
diag(stat1) <- 1
stat1  # this is for the first subset


But now I have two questions:

1. How can I make the dependence hypothesis test among the variables and set my alpha?
2. How can I make the regression analysis?
-
Can you reformulate your desire for a hypothesis test as a question to ask of your data? We might then see what would be most appropriate. –  conjugateprior Mar 26 '12 at 14:48
add comment

## 1 Answer

Because there are two questions here and I only understand the first, this is the one I will address.

You formulate a hypothesis of independence, which is your null hypothesis. Because you are doing a $\chi^2$ test I assume that this means that items a1, a2, a14 and a21 occur with the same ratio in both lines you test.

The alternative hypothesis is that the sampling of these four categories and the sampling of the two lines you test is dependent. However, in the case of the $\chi^2$ test, the alternative hypothesis is composite, which means that you test the hypothesis of independence against all possible statistical dependencies that will inflate the $\chi^2$ statistic.

For instance if, by a strange phenomenon, the sampling of the 4 items would be such that the numbers would always be strictly identical between the two lines you test, you would never reject independence with the $\chi^2$ test, while the sampling would actually not be independent.

You do not need a specific alternative hypothesis to set $\alpha$ (you need it to know $\beta$ though). The $\alpha$ level is the probably of rejecting the null hypothesis while it is actually true, i.e. when sampling is independent. You just have to choose it depending on the cost being wrong. It is in the statistical culture to set it to 1 or 5% but there is actually no strong argument for it.

-
add comment