adjusted standardized residuals chi square

Hi, I need calculate the adjusted standardized residuals to estimate where we can find the major association between the variables quantity of devices in the bedroom (dev_bed) and marital status (single/couple). I have the next codes:
##MARITAL STATUS
###Contingency table
table(Base_2_testchi$dev_bed, Base_2_testchi$marital_status_rec)
addmargins(Base_2_testchi$dev_bed, Base_2_testchi$marital_status_rec)#no funciona
sjt.xtab(Base_2_testchi$dev_bed, Base_2_testchi$marital_status_rec)

##test chi
Test_Chi_MStatus<-chisq.test(Base_2_testchi$dev_bed,Base_2_testchi$marital_status_rec)
#Result
Test_Chi_MStatus
tables
Test_Chi_MStatus$observed
Test_Chi_MStatus$expected
Test_Chi_MStatus$residuals

#Export to excel(test_Chi$expected,"Chiexpected.xlsx")
write.xlsx(Test_Chi_MStatus$observed,"chiobserved_MStatus.xlsx")
write.xlsx(Test_Chi_MStatus$expected,"chiexpected_MStatus.xlsx")

#Standarized residuals
Test_Chi_MStatus$stdres

#Level of significance
sig <-.05

Bonferroni adjustment

sigAdj_MStatus<-sig/(nrow(Test_Chi_MStatus)*ncol(Test_Chi_MStatus))
sigAdj_MStatus

#Z value
qnorm (sigAdj_MStatus/2)

For the last part of the codes, the console shows:

Test_Chi_MStatus$stdres

Base_2_testchi$dev_bed En pareja missing Sin pareja
0 2.7662096 -1.1018056 -2.5803151
1 -1.0598660 1.7534398 0.7298817
2 -2.2725550 -0.5121060 2.3953097

#Nivel de significancia
sig <-.05

#Ajuste Bonferroni
sigAdj_MStatus<-sig/(nrow(Test_Chi_MStatus)*ncol(Test_Chi_MStatus))
sigAdj_MStatus
numeric(0)

#Z value
qnorm (sigAdj_MStatus/2)
numeric(0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.