anhoej / qicharts2

R package: Quality improvement charts
38 stars 12 forks source link

xbar control limits disappear for large subgroup sizes #16

Closed pwildenhain closed 5 years ago

pwildenhain commented 5 years ago

When I try to create an xbar chart, with a large N size, the control limits disappear from my chart

Here's the reproduced example from the vignette

cabg <- cabg %>% 
  mutate(month = as.Date(cut(date, 'month')))

qic(month, age, data  = cabg, chart = "xbar")

image

However, when I scale up the data set, some of my control limits disappear

cabg_big <- rbind(cabg, cabg, cabg, cabg, cabg)

qic(month, age, data  = cabg_big, chart = "xbar")

image

I get this warning message: In c4(n) : value out of range in 'gammafn'. When I tested the c4() function, I saw that error message specifically occurs when n > 343

> qicharts2:::c4(343)
[1] 0.9992693
> qicharts2:::c4(344)
[1] Inf
Warning message:
In qicharts2:::c4(344) : value out of range in 'gammafn'

Can you help me understand why this is happening?

brndngrhm commented 5 years ago

Would a potential solution be to use the log-gamma function for large sample sizes? See for example this thread.

anhoej commented 5 years ago

Thanks, I'll look into it.

anhoej commented 5 years ago

Fixed on GitHub. Please test and report.

pwildenhain commented 5 years ago

Works perfect, thanks! Thanks for fixing this so quickly, I should've replied as quickly!