2017-11-17 11 views
1

저는 R을 처음 접했고 임무를 수행하면서 선형 회귀 (1360 개의 관측 값과 52 개의 변수가있는 시계열 데이터 (회귀 모델의 11 개 변수)). 최초 연구에서 연구자들은 Hadi 방법으로 이상치를 확인했다. 이것이 mvBacon 함수를 사용하여 R에서 가장 잘 수행 된 것 같습니다. 맞습니까? 나는 이것을 사용하는 방법에 대한 좋은 대답을 찾을 수없는 것 같다. 누군가가이 함수를 사용하여 이상 치를 찾는 방법을 알려 줄 수 있을까? (R은 매우 새롭기 때문에 가능한 한 간단하게 설명하는 답변을 매우 고맙게 생각합니다.) 대단히 감사합니다!R : mvBACON의 이상치 찾기

답변

1

예, mvBACON은 거리를 기준으로 한 이상 값 식별을위한 것입니다. 기본값은 Mahalanobis 거리입니다. 다음 코드는 mvcACON을 사용하여 특이점을 식별하는 방법에 대한 간단한 예제 인 mtcars 하위 데이터 집합을 보여줍니다.

# Use mtcars (sub)dataset and plot it 
data <- mtcars %>% select(mpg, disp) 
plot(data, main = "mtcars") 

# Add some outliers and plot again 
data <- rbind(data, 
       data.frame(mpg = c(1, 80), disp = c(800, 1000))) 
plot(data, main = "mtcars") 

# Use mvBacon to calculate the distances and get the ouliers 
library(robustX) 
distances <- mvBACON(data) 
# Plot it again... 
plot(data, main = "mtcars") 
# ...with highlighting the outliers 
points(data[!distances$subset, ], col = "red", pch = 19) 

# Some fine tuning, since lot of outliers seem to be still good for regression 
distances <- mvBACON(data, alpha = 0.6) 
plot(data, main = "mtcars") 
points(data[!distances$subset, ], col = "red", pch = 19)