# Bayesian inference for outliers detection

Can you please comment, validate, correct my reasoning here?

I want to identify outliers of the value to mass ratio (V/M) of rice, just to give a simple univariate example.

Prior information: rice world market figures say that the ratio is "around" 0.43 euros/kg or 430 euros/1000 kg for the period of time we're studying.

I have total of 467 observations of V/M ratios for the same period of time. Here's the (multimodal) distribution of the data. Say that I consider rice V/M ratio comes from a normal distribution.

I want to estimate the parameters (mean, sd) of the normal posterior distribution in order to determine which V/M observations are actually outliers comlpared to that distribution.

Prior:

• mean of V/M comes from N(mean0 = 0.43, sd0 = .03).

• sd of V/M comes from Gamma(a0=5, b0=20), I actually don't know.

Data: I consider only observations within the first "bump" of the observed data distribution, as shown below. Posterior: I calculate the posterior distributions of the mean and sd parameters. I use R package LearnBayes function normpostsim.

res <- LearnBayes::normpostsim(data = VMratios,
prior = list(mu=c(0.43, .03), sigma2=c(5, 20)),
m = 1000)

> mean(res$mu)  0.5831659 > mean(res$sigma2)
 0.1652519


Thus, after observing the data, my new priors for V/M ratio are now mean1 = 0.583 and sd1 = 0.165.

I use this result to detect outilers, I'm interested in small values of V/M (lower bound).

Q1 <- quantile(res$mu, na.rm = TRUE)[] Q3 <- quantile(res$mu, na.rm = TRUE)[]
IQR <- Q3 - Q1

lower <- Q1 - 1.5*IQR = .518


Thus, from my data I can considered any observed V/M ratio as an outlier if V/M < 0.518