Apply tryCatch function when calculating loesses