# Can I construct a GAM in R for beta binomial data where the response is aggregated?

I have beta-binomial data pi = ri/ni and wish to construct a GAM using R.

My data has columns {Case, X1...Xn, R, N}

Initial thought

Stack Successes(1) & Fail(0) use mgcv:gam with weights ri & (ni-ri) respectively and family = beta. As far as i can see family = beta does not exist. The family betar is for proportions on the open interval (0, 1) rather than count (success, fail) pairs.

The main issue is being able to construct confidence intervals with a good enough overdispersion adjustment.

Other thoughts:

• As above with family quasibinomial
• As above swapping gam with gamm and specifying random effects

My question is

Can I construct a GAM in R for beta binomial data where the response is aggregated?

Edit

I have discovered I can use cbind() in the left hand side of the formula to represent binomial data

result <- gam(data=data,
formula = cbind(r, (n-r)) ~ s(x1, bs = "cs"),

• Why not use family=betar? – Łukasz Deryło Dec 18 '19 at 13:16