0

I want to fit a binomial model using glm package in R however I'm looking for negative values for some of the coefficients. I also have categorical independent variables which are converted to factors.

I was wondering if there is any way to add that constraint to glm or if any other packages available with such capabilities. I've also tried glmnet but the problem with that package is that it doesn't provide the significant value (p value) for all coefficients and also not all variables end up with non zero coefficient using glmnet. So even if a coefficient is not-significant I still need a value for that coefficient.

Basically what I'm looking for is:

target ~ intercept+ B1*X1+B2*X2+B3*X3+B4*X4+...

S.T. B2<0 and B3<0 and B5<0

I appreciate if anyone can help.

Thanks.

Frank
  • 41
  • 2
  • Surely you want B2<0 and not X2<0 etc.? Parameter estimation becomes complicated when you restrict the parameter space. The nice properties of maximum likelihood don't all hold, especially if you want p-values to be produced. You could fiddle more carefully with `glmnet`, such as to set `alpha` to 0 and `penalty.factor` to 0 for all variables. But I'm concerned you might be getting in over your head with all this. – ngm Apr 20 '18 at 18:08
  • The coefficient values are on the logist-scale relative to the (Intercept) value. You should explain in greater detail what (and why) you are attempting to do. – IRTFM Apr 20 '18 at 20:57
  • For the use case that I'm dealing with positive coefficients for some terms doesn't have a meaningful value. Although mathematically the global optimum for the equation might be in a region with positive coefficient but I would like to limit the search space to only cover negative coefficient for some parameters. That is very trivial and it is a common approach in optimization to set boundaries. . Does anyone know how can we achieve the constraint capability by adding a custom code to glm in R? – Frank Jun 06 '18 at 17:42

0 Answers0