R中的GAM具有分类和连续变量? [英] GAM in R with categorical AND continuous variables?

查看:79
本文介绍了R中的GAM具有分类和连续变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想要在 R 中使用 GAM 或 GAMM 查看多个变量对灰海豹丰度的影响(从我的理学硕士研究中收集的数据).我的响应变量是总计数,我有温度、风速的连续变量和月份、季节和潮汐(低/高)的分类变量.

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

上述模型适用于两个连续变量......但我通常不确定什么是合适的模型,以及我是否会更好地使用 GAMM 并且随着时间的推移(数据收集期)更平滑.

我可以创建一个包含所有连续变量和分类变量的模型吗?

对不起,如果这令人困惑,我是 GAM 和 GAMM 的新手......!

解决方案

我正在处理类似的情况.您确实可以同时使用连续变量和分类变量.以下链接有望解决您的任何问题.

但是,您可能需要考虑在 stats.stackexchange.com 而不是 stackoverflow.com 上提问,因为您的问题似乎更多是关于统计方法而不是 R 编程.

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

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

这篇关于R中的GAM具有分类和连续变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆