[R] mgcv bam() with grouped binomial data

Simon Wood s.wood at bath.ac.uk
Tue Jan 31 11:17:24 CET 2012


upgrade to the current mgcv version (see last item in changeLog for mgcv 
1.7-12)

On 01/30/2012 10:04 PM, Casey Olives wrote:
> Hello,
>
> I'm trying to use the bam() function in the R mgcv package for a large set of grouped binary data. However, I have found that this function does not take data in the format of cbind(numerator, denominator) on the left hand side of the formula. As an example, consider the following
>
> dat1<- data.frame(id=rep(1:6, each=3), num=rbinom(18, size=10, prob=0.8), den=rbinom(18, size=5, prob=0.5), x=rnorm(18))
> m1.1<- gam(cbind(num, den) ~ x+s(id, bs="re"), data=dat1, family=binomial)
> m2.1<- bam(cbind(num, den) ~x+ s(id, bs="re"), data=dat1, family=binomial)
>
> Running the above results in
>
>> dat1<- data.frame(id=rep(1:6, each=3), num=rbinom(18, size=10, prob=0.8), den=rbinom(18, size=5, prob=0.5), x=rnorm(18))
>> m1.1<- gam(cbind(num, den) ~ x+s(id, bs="re"), data=dat1, family=binomial)
>> m2.1<- bam(cbind(num, den) ~x+ s(id, bs="re"), data=dat1, family=binomial)
> Error in dev.resids(y, mu, weights) :
>    argument mu must be a numeric vector of length 1 or length 36
>
> Is this a known issue? If so, is there a way to handle it?
>
> Thank you,
>
> Casey
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list