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