5
The presence of missings in the variable weight of a complex sampling is preventing the R from calculating the mean. Initially I tried the na.rm = TRUE
, but it did not work, follows excerpt:
svymean(basedados$variavel , svydesign( id = basedados$estrato , weight =
basedados$peso ),na.rm=TRUE)
Error in na.Weight(data.frame(Weights)) : Missing values in `Weights'
I also tested this version and nothing:
svymean(dp$Dcoracao , svydesign( id = dp$V0024 , weight = dp$teste , na.rm = TRUE
),na.rm=TRUE)
Error in na.Weight(data.frame(Weights)) : Missing values in `Weights'
Then it was suggested another way, which shows another error message, follows excerpt:
svymean(bd$Dcoracao , svydesign(id = bd[which(!is.na(bd$teste)),"V0024"], weight =
bd[which(!is.na(bd$teste)),"teste"]))
Error in tapply(1:NROW(x), list(factor(strata)), Function(index) { : Arguments must have same length
Also: Missed warning messages:
- In x * pweights : length of the larger object is not multiple of the shorter object length
- In x * pweights : length of the larger object is not multiple of the shorter object length
Have you tried to clear the base before using it on
svymean
andsvydesign
? Declare a variabletemp = bd[!is.na(bd$peso),]?
and then run the search on top of those values.– Anthony Accioly
Henry, would it be possible to put the results of
summary(bd)
,str(bd)
in your question?– Carlos Cinelli
@Carloscinelli, the problem was even presenting missings in the variable assigned as Weight, since I had only 12 missings out of 62000, I turned them to zero and continued. Thank you for your attention
– Henrique Pizarro
@Henriquepizarro answer your question with solution you found, not to leave unanswered.
– Carlos Cinelli
@Carloscinelli, thank you for the warning, I’m new to this community.
– Henrique Pizarro