0

I want to include observation weights in the party package mob() function but get the following error message:

m2 <- mob(ab_any ~ rdt_result | pfpr + peak2offpeak + urb_rur + region + fac6type + fac4owner + staff_doctor + supervision_lastvisit + rdt_totalguidelines + imci_guidelines + prov3qualif + mgt_meetings + userfees_routine + timer2observed + rdt2observed + amany2observed + abany2observed + provider_sex + provider_qualifyears + provider_incharge + provider_workhours + training_anyrdt + training_imci + provider_recentsupervision + provider_supervisiondiscuss + childage + childsex + parentage + nearestfacility + parenteduc + consultlength + starthour + waittime + cough + diarrhea + dangersign + real_temp + illnessduration, weights = P4Data$weight1, data = P4Data, model = glinearModel, family = binomial()) Error in if (any(y < 0 | y > 1)) stop("y values must be 0 <= y <= 1") : missing value where TRUE/FALSE needed

Sample weights in the dataset (P4Data$weights1) are non-negative values ranging from 0.29865 to 5.084378, which I then multiplied to create integer valued weights (29865 to 5084378). Note that I do not get any error message if this same function is run but without weights.

Thanks for any guidance.

emilywj
  • 3
  • 2

1 Answers1

0

The error message points out that the range of ab_any does not fit the family = binomial() specification. It should either be a factor or a dummy-coded 0/1 numerical variable. Currently that does not appear to be the case.

As for the weights: The old party implementation always regarded the weights argument as case weights. Thus, multiplying all weights by 10 increases the sample size by 10 which consequently decreases the p-values from the parameter stability tests!

Generally, I would strongly recommend to use the new implementation of mob() in the partykit package which supports either case weights or proportionality weights and has many more improvements and additional features.

Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49
  • Thank you very much. We will review the 'partykit' package to see how to account for clustered data in the algorithm and follow up with any questions. – emilywj Nov 17 '15 at 15:25