dswah / pyGAM

[HELP REQUESTED] Generalized Additive Models in Python
https://pygam.readthedocs.io
Apache License 2.0
852 stars 156 forks source link

Inquiry on Discrepancies Between pyGAM and R GAM Model Results #345

Open Wenhuan2516 opened 4 months ago

Wenhuan2516 commented 4 months ago

Dear pyGAM Developer Team,

I am writing to seek clarification on an issue I have encountered while using the pyGAM package. Specifically, I have noticed discrepancies in the results when fitting a Generalized Additive Model using pyGAM with Python, as compared to using the mgcv package in R, despite using the same dataset and equivalent model specifications. To provide a brief context, I am analyzing the relationship between daily temperature and suicide rates. I am fitting GAMs to subgroups of my data, such as by gender and age groups, and while the results in R seem to be consistent with my expectations, the outcomes produced by pyGAM are notably different. Could you offer any insights into why there might be differences in the results between the two packages? Are there any inherent differences in the default settings or the algorithms used by pyGAM that could account for such discrepancies? Here is a brief overview of the model I am fitting: model = LinearGAM(s(0, n_splines=7) + s(1, n_splines=7) + s(2, n_splines=14) + f(3)).fit(X, y), while s0 is temperature, s1 is precipitation, s2 is date, f3 is national holidays. In R, I am using the equivalent gam function from the mgcv package with similar spline specifications. Understanding these differences is crucial for the integrity of my research, and any guidance you can provide would be greatly appreciated. Additionally, if there are recommended practices for ensuring the comparability of GAM results across different software implementations, I would be eager to learn more about them.

PDP male female race_white