Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- backwardElimination <- function(x, sl) {
- numVars = length(x)
- for (i in c(1:numVars)){
- regressor = lm(formula = Profit ~ ., data = x)
- maxVar = max(coef(summary(regressor))[c(2:numVars), "Pr(>|t|)"])
- if (maxVar > sl){
- j = which(coef(summary(regressor))[c(2:numVars), "Pr(>|t|)"] == maxVar)
- x = x[, -j]
- }
- numVars = numVars - 1
- }
- return(summary(regressor))
- }
- SL = 0.05
- dataset = dataset[, c(1,2,3,4,5)]
- backwardElimination(training_set, SL)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement