Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Tag Info

Hot answers tagged gamm4

8

I'm not sure what you want here. Have you looked at ?predict.gam # Load the gamm4 package library(gamm4) # Using gamm4's built-in data simulation capabilities to give us some data: set.seed(100) dat <- gamSim(6, n=100, scale=2) # Fitting a model and plotting it: mod <- gamm4(y~s(x0)+s(x1)+s(x2), data=dat, random = ~ (1|fac)) plot(mod$gam, pages=1) ... 6 First, rewriting the$QR$decomposition in a (hopefully) clearer way by showing the partitioning of$Q$and explicitly giving the dimensions of the$0$matrix: $$X=QR=[Q_f,Q_g]\left[\begin{array}{c}R_1\\0_{(n-p)\times p}\end{array}\right]=Q_fR_1$$ So I think part of the confusion here is that in the book you are referring to,$R$is not the$R$of the$...

3

Your error message "weights must be like glm weights for generalized case" is saying that if you choose to use Gamm() with a generalized case (which means: using a non-Gaussian probability distribution such as Gamma) then the weights argument should be specified as it would be for GlmmPQL(). The explanation is that GAMM is essentially a wrapper function ...

2

This model is possible with the brms R package which is an interface to R: A slight modification of one of the examples from https://cran.r-project.org/web/packages/brms/vignettes/brms_distreg.html shows essentially what is involved in setting up and fitting the model ## load package library('brms') ## load data zinb <- read.csv("http://stats.idre.ucla....

2

Yes, they are included, but only ever for the observed levels of the random factor. You can turn this using the by variable smooth trick however. Consider the following example taken from ?gam.models: dat <- gamSim(1,n=400,scale=2) ## simulate 4 term additive truth ## Now add some random effects to the simulation. Response is ## grouped into one of 20 ...

1

I would suggest a different strategy, fitting this as a GAM via gam(), and using a count distribution as the real response variable is an integer count. The response should be Items in this setting. We do need to standardise by the effort but we can do that using a offset in the model. An offset is a term that has a fixed coefficient of 1, and it's ...

1

No, ocat doesn't work with gamm4(). From ?family.mgcv As well as the standard families documented in family (see also glm) which can be used with functions gam, bam and gamm, mgcv also supplies some extra families, most of which are currently only usable with gam, although some can also be used with bam... (emphasis added). ...

1

You could add s(Year) + s(Year, by = area, m = 1) which will generate a common trend (s(Year)) and area-specific smooth departures from this common trend. The m = 1 in the area-specific term use a penalty on the first derivative of the spline and hence penalises departures from a flat, horizontal line, which when coupled with the common trend models how the ...

1

I would try running this using the bam() function in the mgcv which is designed for large data problems. You can add the simple random effects via a random effect spline s(transmitter, bs = "re") in the bam() formula, but this might cause you new problems as random effects in gam()/bam() don't make use of the sparsity of the model matrix of the random ...

1

library(gamm4) set.seed(0) dat <- gamSim(1,n=400,scale=2) ## simulate 4 term additive truth ## Now add 20 level random effect 􏰁fac􏰀... dat$fac <- fac <- as.factor(sample(1:20,400,replace=TRUE)) dat$y <- dat\$y + model.matrix(~fac-1)%*%rnorm(20)*.5 #gamm4 5 br <- gamm4(y~s(x0)+x1+s(x2),data=dat,random=~(...

Only top voted, non community-wiki answers of a minimum length are eligible