Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • GAM in Stata

    I'm trying to do a generalized additive model (GAM) with a spline in stata. I usually do it in R and the code is:
    gam <- gam(winner ~ age + prev_experience + female + s(testscore), family = binomial, data)

    I'm trying to do this code in stata using the gam command. I have:
    gam winner age prev_experience female testscore, family = binomial

    but if I don't specify the df it says the model is linear and does a normal logit regression, I don't want to specify the df the model is supposed to estimate it. Also how do I specify the spline for testscore, in R it's s(testscore) but there doesn't seem to be an equivalent option in the gam syntax for stata. Any suggestions??

  • #2
    Presumably by gam you mean gam from http://www.homepages.ucl.ac.uk/~ucakjpr/stata

    It's not a criticism of anyone, but intended as factual comment, that like most community-contributed commands that one does what the authors want(ed) to do. It's not been revised for some time. Manifestly, it is not offered as a one-to-one equivalent of anything in R.

    So, I doubt that it will do what you want. Guessing wildly, but I think you might need to create spline variables for all predictors but female and then fire up a generalized linear model.
    Last edited by Nick Cox; 25 Apr 2024, 05:08.

    Comment

    Working...
    X