Skip to content
Prev 326139 / 398503 Next

use of formula in survey analysis with replicated weights

Le vendredi 28 juin 2013 ? 17:44 +0200, LE TERTRE Alain a ?crit :
Here is a workaround:
Myformula <- "api00 ~ api99"

withReplicates(bclus1, quote(coef(rq(formula(Myformula), tau=0.5, weights=.weights))))

This solution makes sure the formula uses the environment where the
weights are available. If you call as.formula() from outside the
function, it will use the global environment. If you pass a character
string, it will be converted to a formula object deep in a function and
will thus use an environment where the weights are not be available
either.

Note that the same problem happens when using lm().


Regards