1

After scrambling through the internet, related questions and trying for days without any success I hope you can potentially help me out with the inclusion of optim() with or for a polr() function in R.

What I am trying to do, is to just set some constraints (lower and/or upper bounds for the coefficients). If you'd have a general example of how this would work, I'd be more than delighted.

Let's consider the following fake and senseless data:

set.seed(3)

my.df <- data.frame(id = 1:1000, y = sample(c(1,2,3), 1000, replace = TRUE),
a = rnorm(5000, 1, 0.1), b = rnorm(100, 1.9, 0.5), c = rnorm (10, 0.8, 1.2))

and a polr function like this:

model <- polr(y ~ a + b + c, method = 'logistic')

I do get a coefficient for c, which is negative (albeit insignificant), but I know it's relation to y being positive. Thus, I want to constrain it's coefficient to being positive and I think I can do this with optim().

I want to include something along the lines:

optim(model, method = "L-BFGS-B", lower = c(a = -1, b = -1, c = 0))

which doesn't work.

I think there might be some option with including the optim() function into the polr function using the (to me) arcane ...but I just cannot figure out how. Any ideas?

Much appreciated, and believe it or not, I really tried hard.

Al_
  • 89
  • 1
  • 7
  • Your question is much more likely to get attention if you follow the guidelines [here](http://stackoverflow.com/help/mcve) and [here](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). In particular, since you provide no data any answer will be speculative, and speculative answers are generally discouraged on SO. – jlhoward Oct 21 '15 at 13:30
  • Hi Jihoward, thanks for the feedback. However I got feedback earlier on crossvalidated that non-statistical questions, but programming questions (without) data, would be suitable for SO, no? Will update in a second. – Al_ Oct 21 '15 at 14:16

0 Answers0