New answers tagged

3

You need to be careful with ordered factors here in mgcv as they aren't doing what I think you want to be fitting. If you pass an ordered factor to by, then gam() etc set up a smooth for all the levels except the reference level, and further more they are set up as smooth differences between the reference level and the level for a specific smooth. What is ...


0

It's not the Lasso, but it has the same effect; Marra & Wood (2011) proposed two options for this and describe several other ways to do feature selection in GAMs. Both proposals involve modifying the usual ridge/wiggliness penalty(ies), which do not affect the perfectly smooth basis functions (the null space of the basis), such that the model can ...


1

[I'm going to assume that you are using mgcv as indicated by the mgcv tag; if you aren't, consider switching to it as it provides a much more modern approach to estimating GAMs than the gam package.] It seems like you want to model a bivariate smooth or smooth interaction between x1 and x2. If you want to model a smooth interaction between two variables ...


0

Try something like: mygam = gam (y ~ s(x1, x2), family=binomial, data=mydata3) In your original code, I believe you're treating x1 and x2 distinctly rather than jointly. Combining the two into a single smooth may help. You might also want to investigate other smoothers besides s. Of course, you are using smoothing and things can only be so flexible.


2

I not sure what you are trying to achieve by setting the smoothness parameter of the smooth function directly. If you are simply trying to fix the wiggliness of the smooth at some value then you would be better off fixing the effective degrees of freedom (EDF) of the smooth by setting k to the required value and also using fx = TRUE in the definition of the ...


1

First of all I would recomment this book here to you: Hands-On Machine Learning with Scikit-Learn and TensorFlow There you can read about overfitting, underfitting and the reasons. You can imagine overfitting as a process where the model remembers the training data to detailed and can not generalize to the test or validation data. In summary you can say ...


0

The mgcv package contains a scaled-t family for the conditional distribution of the response, that, like the Gaussian, has support for the entire real line (is suitable for a response that is continuous and is bounded at -Inf and +Inf), but which has heavier tails than the Gaussian. Estimating the model requires estimating another parameter of the ...


1

I would start with the raw count, the actual number of animals found. This would be an integer number. The model I would start with would be a Poisson as the count response is strictly non-negative and discrete (can't have 2.5 animals). I would include an offset in the model that was the number of traps. An offset term is a term that receives a fixed ...


1

Your model didn't work fine, not if that is the model you ran anyway, as the gam() function doesn't have an argument random. This looks like lme4 notation so did you use gamm4() instead of gam()? If you used gam(), your random effect was silently eaten by the ... argument and promptly ignored. Using plot() on the model (the $gam component of the model in ...


2

Where is the idea coming from that GCV will automatically choose the number of knots? The number of knots (i.e., the basis dimension) is fixed and cannot be changed during model fit. What the GCV score in function gam() is doing "automatically" is not choosing the basis dimension k, as Ira S says, but is choosing the smooth level of each basis spline by ...


0

I have read a paper (Benjamins et al., 2017 Harbour porpoise distribution can vary at small spatiotemporal scales in energetic habitats) in which they do exactly this. They also provide the R code that they used, you might want to check it? They basically generate variance-covariance matrices for the cyclic covariates, and include these in the GEE. Here's ...


Top 50 recent answers are included