I need to compute some ratios using a survey.

I manage to calculate regional totals after especifying a list of variables (regions).

Regions are dummies from 1 to 17, taking the value of 1 if the observation belongs to the region1.

This code works. It computes totals by regions using the variable s3

Code:

`lapply( regions , function( z ) svyby( as.formula( paste0( "~" , z ) ) , by = ~s3, design=ddd, svytotal , vartype = 'cv',na.rm=T ) )`

Here I'm pretending to obtain the ratio s3/s1 for each regional dummy:

Code:

`lapply( regions , function( z ) svyby( as.formula( paste0( "~" , z ) ) , by = ~s3, denominator=~s1, design=ddd, svyratio, vartype = 'cv',na.rm=T ) )`

These are the totals using lappy for the 17nth region:

0.0683...=617.487/9031544->That's ok

Using lapply for computing the same ratio in the 17nth region, I get this :

I have no idea the reason for this output.

Thanks for your time, interest and replies.