Hi everyone,
I am trying to fit a GAM model with Poisson rates data which include an offset term. I have tried using this code:
proc gam data=mydata;
model dv=spline(x1) spline(x2) splineline(x3) / dist=poisson link=log offset=lexp anodev=norefit;
output out=mydout p;
run;
For some reason the offset term is indicated as an error in the log file.
I am not sure how can I indicate I am dealing with rates not with counts. If I do not specify an offset term, the smoothing is being done for the count data, right?
I also have a question about testing the linearity of the association - is this a sound procedure?
1. I wanted to test each of the independent variables to see if they display a linear or quadratic association with my dependent variable - that is why I tried using GAM.
2. In case GAM indicates only significant linear tends for all my predictors except for one, can I still use then proc genmod with an offset (which I ran; it worked just fine, assuming a linear association, no weird coefficients).
I was also considering using the proc adaptvereg, not sure that is a better option in my case.
Thank you very much for taking the time to read my post and to help me!
Best regards1
If you have SAS/STAT 14.1, I highly recommend switching to the GAMPL procedure, which is a completely rewritten faster implementation of GAM. You can see an example and links at the article "Nonparametric regression for binary response data in SAS". The GAMPL procedure handles Poisson data and supports the OFFSET= option.
Yes, the offset term enables you to fit rates (counts per time period).
In your syntax for PROC GAM, I am unfamiliar with the SPLINELINE effect. It is not in the documentation.
If you have SAS/STAT 14.1, I highly recommend switching to the GAMPL procedure, which is a completely rewritten faster implementation of GAM. You can see an example and links at the article "Nonparametric regression for binary response data in SAS". The GAMPL procedure handles Poisson data and supports the OFFSET= option.
Yes, the offset term enables you to fit rates (counts per time period).
In your syntax for PROC GAM, I am unfamiliar with the SPLINELINE effect. It is not in the documentation.
Hello Rick_SAS,
Thank you so much for your response and for the suggestions!
I am so sorry: the "splineline" was a typo - I meant "spline".
I also found a macro that is useful to test non-linearity - %glmcurv9 that I found here: http://www.hsph.harvard.edu/donna-spiegelman/software/.
I will perform a GAML analysis, too, and compare the results.
Thanks!
Hello Rick,
Sorry to bother you again, I was just wondering whether it is still possible to run GAM with an offset. It seems that it is not possible.
I only have access to BaseSAS on this computer, but I will use the student version of SAS/STAT14.1 and run GAML later on using my computer.
Thanks!
If you haven't already done so, please bookmark the SAS/STAT documentation. The doc for the GAM procedure contains all valid syntax. Just click the MODEL statement.
Hi again,
Thank you so much for all your help! Have a great weekend!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.