Domanda

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?

È stato utile?

Soluzione

Simply:

ff <- lrm( Target ~  var1 + , data = dat ,subset=var1>=quantile(var1, 0.07) & var1<=quantile(var1, 0.09))
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top