3
$\begingroup$

Suppose I have a data set, and have trained up a regression model (happens to be a bayesian linear model, I'm just using the R package). The model outputs a wide range of values, greater than 0 and less than 0, although the actual output can only be greater than 0.

Is there an accepted away to apply bounds to the output of a model to "force" it into a possible value? Or is it perhaps an indicator that I'm doing something wrong or applying the wrong technique to my problem?

$\endgroup$
4
  • 2
    $\begingroup$ Please precise. What is the R package you use ? What are the output values you are talking about ? Are they the estimates of the parameters ? Why can they only be greater than 0 ? $\endgroup$ Commented Mar 12, 2012 at 20:29
  • $\begingroup$ I'm using the TGP package, but I think the question is more general than that-- I'm wondering about the actual prediction values that are made by the model on the test set. The fact that the predicted value should be greater than 0 comes from what we know about the domain. Negative values do not make sense for what we're trying to predict. $\endgroup$
    – Denise
    Commented Mar 12, 2012 at 20:33
  • $\begingroup$ So you fit a model on a training set with no negative values and when you use it on the test set it is producing negative numbers even though there were none in the training set and there is no reason to expect it to produce them for the test set? $\endgroup$
    – asjohnson
    Commented Mar 12, 2012 at 20:42
  • $\begingroup$ yes, that's right. $\endgroup$
    – Denise
    Commented Mar 12, 2012 at 20:50

1 Answer 1

1
$\begingroup$

Are you by chance modeling count data? You need to use a Poisson or Negative Binomial regression for count data, otherwise you can end up with negative predictions.

$\endgroup$
5
  • $\begingroup$ it's sort-of count data. I'm modeling a ratio of two events (think, something like click-through-rate). I thought about predicting the number of the two separate events and then dividing, but it actually didn't turn out as well as just predicting the ratio. $\endgroup$
    – Denise
    Commented Mar 12, 2012 at 21:37
  • $\begingroup$ Then you could model the number of clicks using a Poisson or Negative Binomial regression as suggested by @Wayne and treat the impressions (number of times the ad is shown) as the offset. $\endgroup$
    – boscovich
    Commented Mar 12, 2012 at 22:03
  • $\begingroup$ that might work, except that the number of impressions is unknown as well. $\endgroup$
    – Denise
    Commented Mar 13, 2012 at 13:49
  • $\begingroup$ @Denise: Have you tried Poisson regression on the two events and divide? Might work a lot better than the division you did previously between the two improper regressions. $\endgroup$
    – Wayne
    Commented Mar 13, 2012 at 23:49
  • $\begingroup$ But in any event, +1 for Wayne's answer because I think the fundamental issue is that: rather than trying to constrain the results of an OLS regression, you should try to use some other kind of model, probably still a generalized linear model but not with a gaussian response. $\endgroup$ Commented Mar 14, 2012 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.