Lets say I have 7 independent variables (x1 to x7) that I determined to be important variables in predicting y using forward selection (stepAIC function):

```
y <- rep(c('Positive', 'Negative'), each = 20)
x1 <- rnorm(40, 1, .1)
x2 <- rnorm(40, 1, .1)
x3 <- rnorm(40, 1, .1)
x4 <- rnorm(40, 1, .1)
x5 <- rnorm(40, 1, .1)
x6 <- rnorm(40, 1, .1)
x7 <- rnorm(40, 1, .1)
```

I make an overall score using the 7 x variables. Now I want to weight these variables to produce the highest AUC value. What would be the code to do this? Basically I want to see which values (or weights) I could multiply by each x variable to produce the highest AUC.

```
score <- x1 + x2 + x3 + x4 + x5 + x6 + x7
dat <- data.frame(y, score)
library(pROC)
glm.fit <- glm(y ~ score, family = binomial, data = dat)
a <- roc(dat$y, glm.fit$fitted.values)
a$auc
```

Thanks!

- Serverfault Help
- Superuser Help
- Ubuntu Help
- Webapps Help
- Webmasters Help
- Programmers Help
- Dba Help
- Drupal Help
- Wordpress Help
- Magento Help
- Joomla Help
- Android Help
- Apple Help
- Game Help
- Gaming Help
- Blender Help
- Ux Help
- Cooking Help
- Photo Help
- Stats Help
- Math Help
- Diy Help
- Gis Help
- Tex Help
- Meta Help
- Electronics Help
- Stackoverflow Help
- Bitcoin Help
- Ethereum Help