search for: outlier_counter

Displaying 1 result from an estimated 1 matches for "outlier_counter".

2011 Feb 09
5
Removing Outliers Function
...8,10,8,11,13,14,14,15,85,17,19,19,20) data1 = data.frame(x,y) rm.outliers = function(dataset,dependent,independent){ dataset$predicted = predict(lm(dependent~independent)) dataset$stdres = rstudent(lm(dependent~independent)) m = 1 for(i in 1:length(dataset$stdres)){ dataset$outlier_counter[i] = if(dataset$stdres[i] >= 3 | dataset$stdres[i] <= -3) {m} else{0} } j = length(which(dataset$outlier_counter >= 1)) while(j>=1){ print(dataset[which(dataset$outlier_counter >= 1),]) dataset = dataset[which(dataset$outlier_counter == 0),] dataset$pred...