Pregunta

I have a line of code that calculates logistic regression based on 2 variables where one variable's values are above its mean:

ff <- lrm(Target ~  var1 + , data = dat ,subset = var1>=mean(var1))

I would like to change the mean to a percentile: for example do the subset on observations where the value of var1 is higher than the 7th percentile and less than the 9th percentile.

How can I do it?

¿Fue útil?

Solución

Simply:

ff <- lrm( Target ~  var1 + , data = dat ,subset=var1>=quantile(var1, 0.07) & var1<=quantile(var1, 0.09))
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top