Skip to content
Prev 326141 / 398503 Next

RE : use of formula in survey analysis with replicated weights

Thanks for the workaround and the explanation

Alain
________________________________________
De : Milan Bouchet-Valat [nalimilan at club.fr]
Date d'envoi : vendredi 28 juin 2013 19:20
? : LE TERTRE Alain
Cc : 'R-help at r-project.org'
Objet : Re: [R] 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