Chi-square command in ds.table gives error

Hello all, I am getting an error when asking the computation of the chi-square, any suggestion please?

  •      ds.table(rvar="ext_pcbin_df$prepreg_dep",
    
  •      cvar="ext_pcbin_df$eusilc_income_quintiles",
    
  •      report.chisq.tests = TRUE,
    
  •      exclude =c("NaN", "NA"), 
    
  •      useNA= "no")
    

Data in all studies were valid

Study 1 : No errors reported from this study Study 2 : No errors reported from this study Study 3 : No errors reported from this study Study 4 : No errors reported from this study Study 5 : No errors reported from this study Study 6 : No errors reported from this study Study 7 : No errors reported from this study

  • Error in stats::chisq.test(input.array.source.specific) : at least one entry of ‘x’ must be positive

Thanks

Hi Gabriella,

Could you let us know which version of dsBase and dsBaseClient you are using?

Regards, Stuart

Hi Stuart,

I have the following:

dsBaseClient_6.1.0
DSOpal_1.1.0 DSI_1.1.0
R6_2.4.0
progress_1.2.2
opalr_1.4.1
httr_1.4.2

but cannot see dsBase…

Thanks, Gabriella

Hi Gabriella,

Here are the 1D tables for each one of those variables:

                  study
nonrep$prepreg_dep    1     2     3    4     5    6    7     8
                0  7057 96911     0    0     0    0    0 11458
                1   237  6791     0    0     0    0    0  1136
                NA  348  2343 96825 1678 18329 2868 2270  3051
                           study
nonrep$eusilc_income_quintiles    1     2     3   4    5    6   7    8
                            1  1402 18249 16368 308 2708    0 383 2158
                            2  1402 18058 16470 304 2709    0 387 2166
                            3  1402 17436 16370 304 2709    0 387 2152
                            4  1401 19287 16417 304 2709    0 385 2187
                            5  1404     0 16417 303 2709    0 385 2126
                            NA  631 33015 14783 155 4785 2868 343 4856

As you can see prepreg_dep includes only NAs in studies 3 to 7 (those are dnbc, chop, elfe, raine, and inma in that order). So if you do a 2D table of the two variables for the other 3 studies (ninfea, moba and alspac) you can then get the results of the chi-squared test:

$chisq.tests
$chisq.tests$chisq.test_TABLE.STUDY.1_counts

	Pearson's Chi-squared test

data:  input.array.source.specific
X-squared = 16.747, df = 4, p-value = 0.002165


$chisq.tests$chisq.test_TABLE.STUDY.2_counts

	Pearson's Chi-squared test

data:  input.array.source.specific
X-squared = NaN, df = 4, p-value = NA


$chisq.tests$chisq.test_TABLE.STUDY.3_counts

	Pearson's Chi-squared test

data:  input.array.source.specific
X-squared = 231.13, df = 4, p-value < 2.2e-16


$chisq.tests$chisq.test_TABLES.COMBINED_all.sources_counts

	Pearson's Chi-squared test

data:  combine.array.all.sources
X-squared = 154.81, df = 4, p-value < 2.2e-16



$validity.message
[1] "Data in all studies were valid"

Great, thanks! I thought I was factoring out NAs through the commands exclude and useNA, but nope! Thanks again

thanks for the awesome information.