Search code examples
rsurveyp-valuechi-squared

Can you use a reciprocal condition when getting "Error in solve.default" when using svychisq


I'm working on a large weighted national dataset and keep running into the following error when using the svychisq() function. The overall dataset has 7552 observations with 784 variables, however I am getting this error code for some subsets I created with 1,000-2,000 observations. The following code includes "NM.svy" as a weight data frame for one of those subsets.

svychisq(~RaceEth + BFDur, NM.svy, statistic = "Wald")  

Error in solve.default(V[use, use], Y[use]) :  system is computationally singular: reciprocal condition number = 4.34304e-22

I only run svychisq() to get a p-value score so would it be okay to use the reciprocal condition number of "4.34304e-22" to represent the value of p to determine significance? I know there are probably fixes to the error but since the data is weighted and larger it might be a bit complicated just to get one number.

Below is what I get when I run a table on the weighted dataframe.

table( NM.svy$variables[ c( 'RaceEth' , 'BFDur' ) ] , useNA = 'always' )

This is usually what I get when the chi-square is produced.

Design-based Wald test of association data:  svychisq(~RaceEth + BF5EVER, IL.svy, statistic = "Wald") F = 10.733, ndf = 5, ddf = 1203, p-value = 4.124e-10

Solution

  • Thank you so much for the answers. After running the table I realized the issue was that the responses weren't evenly distributed. So, I recoded the outcomes to only those I wanted, throwing the rest into an "other" category and that worked!