Hi! I have two dimensional dataset which has and I need to decide if a point lies in some "confidence level". If a point has low confidence/density it can be anomaly which I need to find. For example: #load library library(sm) #get some data x.locs = c(74, 74.5, 75, 77,74.5) y.locs = c(64, 63.5, 63, 61,61.5) points = cbind(x.locs, y.locs) #plot it plot(points) #get points density abc=sm.density(points, eval.points=points, eval.grid=FALSE) #make a matrix from points and estimation fc=cbind(abc$eval.points,abc$estimate) #select points upper and lower "confidence" level fca=subset(fc,fc[,3]>0.08) fcb=subset(fc,fc[,3]<=0.08) #show how contours look like with sm "nature" contour function dens.2 =sm.density(points,display="slice") #finally plot contour- green points are ok, red are some anomalies contour(dens.2$eval.points[,1],dens.2$eval.points[,2],dens.2$estimate) points(fca,col="green") points(fcb,col="red") This is OK. From some reason I'm not able to use sm.density display="slice" with estimation on points. This is first problem. Second is that when I use it with my dataset which has around 46000 points the contours are too much rounded- it makes a circle, but data has more ellipse shape aproximation. I have tried to work with h parametr, but without success. My best result looks: https://github.com/matejuh/doschecker_wiki_images/raw/master/linear_regression/density/sm_density.png Btw. if you have some advice how to write example upper better or you have some suggestion that I can use another library I will appriciate it. Thanks in advance Matej Plch