简体   繁体   中英

GAM in R with categorical AND continuous variables?

Wanting to see the effects of multiple variables on grey seal abundance (data collected from my MSc research) using a GAM or GAMM in R. My response variable is total count, and I have continuous variables of temperature, windspeed and categorical variables of month, season and tide (low/high).

gam(YthanCount$Total~s(YthanCount$Temperature)+s(YthanCount$Windspeed)

The above model is for the two continuous variables....but I am just generally unsure what an appropriate model would be, and if I would be better using GAMM with a smoother over time (data collection period).

Can I create a model with all of my continuous and categorical variables?

Sorry if this is confusing, I am new to GAMs and GAMMs...!

I'm am dealing with a similar situation. You can indeed use both continuous and categorical variables. The links below will hopefully resolve any questions you have.

However, you may want to consider asking your question at stats.stackexchange.com rather than stackoverflow.com, as your question(s) seem to be more about statistical methods than about R programming.

https://kevintshoemaker.github.io/NRES-746/GAMs.html

https://www.fromthebottomoftheheap.net/2014/05/09/modelling-seasonal-data-with-gam/

https://petolau.github.io/Analyzing-double-seasonal-time-series-with-GAM-in-R/

https://cran.r-project.org/web/packages/itsadug/vignettes/acf.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM