William Shadish
2014-Feb-03 21:00 UTC
[R] package mgcv - predict with bam: Error in X[ind, ] :, subscript out of bounds
Dear Simon, your note below says "bs="re" specifies a Gaussian random effect ". I have been using bs = "re" for data modeled with Poisson and binomial distributions, or variants thereof (e.g., quasi-Poisson). Have I erred in assuming bs ="re" can be used to obtain random effects for such data? Will Shadish - Actually this is ok. mgcv exploits the duality between quadratically penalized smooths and Gaussian random effects to allow random effects to be specified this way. bs="re" specifies a Gaussian random effect with corresponding model matrix given by model.matrix(~site-1). (More generally s(x,y,z,bs="re") specifies a gaussian random effect with model matrix given by model.matrix(~x:y:z-1), with obvious generalization to more or fewer variables). See mgcv help file ?random.effects for more. best, Simon -- William R. Shadish Distinguished Professor Founding Faculty Mailing Address: William R. Shadish University of California School of Social Sciences, Humanities and Arts 5200 North Lake Rd Merced CA 95343 Physical/Delivery Address: University of California Merced ATTN: William Shadish School of Social Sciences, Humanities and Arts Facilities Services Building A 5200 North Lake Rd. Merced, CA 95343 209-228-4372 voice 209-228-4007 fax (communal fax: be sure to include cover sheet) wshadish at ucmerced.edu http://faculty.ucmerced.edu/wshadish/index.htm http://psychology.ucmerced.edu
Gavin Simpson
2014-Feb-03 23:33 UTC
[R] package mgcv - predict with bam: Error in X[ind, ] :, subscript out of bounds
The two distributions are different. The random effect is assumed to be a Gaussian random variable, just as it is with the GLMMs in the lme4 package. It is fine to use such a random effect within a GAM with a non-Gaussian error distribution, like the ones you describe using. HTH Gavin On 3 February 2014 15:00, William Shadish <wshadish at ucmerced.edu> wrote:> Dear Simon, your note below says "bs="re" specifies a Gaussian random effect > ". I have been using bs = "re" for data modeled with Poisson and binomial > distributions, or variants thereof (e.g., quasi-Poisson). Have I erred in > assuming bs ="re" can be used to obtain random effects for such data? Will > Shadish > > - Actually this is ok. mgcv exploits the duality between quadratically > penalized smooths and Gaussian random effects to allow random effects to > be specified this way. bs="re" specifies a Gaussian random effect with > corresponding model matrix given by model.matrix(~site-1). (More > generally s(x,y,z,bs="re") specifies a gaussian random effect with model > matrix given by model.matrix(~x:y:z-1), with obvious generalization to > more or fewer variables). See mgcv help file ?random.effects for more. > > best, > Simon > > > -- > William R. Shadish > Distinguished Professor > Founding Faculty > > Mailing Address: > William R. Shadish > University of California > School of Social Sciences, Humanities and Arts > 5200 North Lake Rd > Merced CA 95343 > > Physical/Delivery Address: > University of California Merced > ATTN: William Shadish > School of Social Sciences, Humanities and Arts > Facilities Services Building A > 5200 North Lake Rd. > Merced, CA 95343 > > 209-228-4372 voice > 209-228-4007 fax (communal fax: be sure to include cover sheet) > wshadish at ucmerced.edu > http://faculty.ucmerced.edu/wshadish/index.htm > http://psychology.ucmerced.edu > > ______________________________________________ > 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.-- Gavin Simpson, PhD