Вопрос

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?

Это было полезно?

Решение

Simply:

ff <- lrm( Target ~  var1 + , data = dat ,subset=var1>=quantile(var1, 0.07) & var1<=quantile(var1, 0.09))
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top