<p>I'm surprised you haven't run into this several times already!</p>

<p>Writing an answer that helps the user (which you clearly did) doesn't make the answer on-topic. It's nice to help a user when we can but the question must still be on topic to stay open. [I've given dozens of answers to questions that were marked off topic - indeed, after reflection, I have marked as off topic a few questions I gave answers to myself.]</p>

<p>There are several things you can do about a question marked off-topic:<br>
- where possible, you can encourage the OP to edit the question to make it more clearly on-topic (or if you could edit it yourself if you don't change the general sense of the question)<br>
- if there's another SE site for which it is clearly on topic you can flag to migrate (and perhaps earn reputation there)<br>
- if there's another SE site for which it <em>would be</em> on topic after an edit you can encourage the OP to edit to make it so (or again, edit yourself if you don't change the sense of the question), and you can flag to migrate  </p>

<p>I presume you refer to <a href="https://stats.stackexchange.com/questions/168978/multi-class-logistic-generalized-additive-models/168979#168979">this answer</a>. In that case, to be <a href="https://stats.stackexchange.com/help/on-topic">on topic</a> here, it would need to ask a more clearly statistical question than "which package do I need?"; with some (different) edits it might be on topic on StackOverflow or possibly another SE site.</p>

<p>You don't lose reputation when a question is closed. Deletion, however, <a href="https://meta.stackexchange.com/questions/7237/how-does-reputation-work">can affect reputation</a> in some circumstances (see the answer, under "Additionally").</p>
