[R] proportional odds logistic regression with non-negative constraint for several coefficients
Rune Haubo
rune.haubo at gmail.com
Sat Jan 28 11:36:32 CET 2017
Hi Zhao,
This is not a direct answer to your question, but a suggestion for a
different approach. The ordinal package was designed to cope with
issues like this (parameter constraints in ordinal regression models)
- try the following:
> library(ordinal)
> data(wine, package="ordinal")
> ## Fit model for reference:
> fm1 <- clm(rating ~ temp + contact, data=wine)
> # summary(fm1)
> coef(fm1)
1|2 2|3 3|4 4|5 tempwarm contactyes
-1.344383 1.250809 3.466887 5.006404 2.503102 1.527798
>
> ## Now fit the same model by manually optimizing a clm-environment:
> env <- clm(rating ~ temp + contact, data=wine, doFit=FALSE)
> # ls.str(env) ## view contents of env
> ## Define negative log-likelihood function:
> nll <- function(par, envir) {
+ envir$par <- par
+ envir$clm.nll(envir)
+ }
> ## optimize with nlminb:
> nlminb(start=env$par, objective=nll, envir=env)$par
[1] -1.344385 1.250812 3.466887 5.006404 2.503102 1.527798
>
> # Now optimize under parameter constraints:
> nlminb(start=env$par, objective=nll, envir=env,
+ upper = c(Inf, Inf, Inf, Inf, 2, 1),
+ lower = rep(-Inf, 6))$par
[1] -1.6124363 0.8060461 2.8052591 4.2401832 2.0000000 1.0000000
>
Cheers
Rune
On 26 January 2017 at 20:41, Liu, Zhao <Zhao.Liu at fmglobal.com> wrote:
> Hi,
>
> I am working on proportional odds logistic regression, and trying to figure out how to specify the constraint for several predictors. Those non-negative constraints for some predictors are for practical purpose.
>
> I have seen some one posted passing box constraint with L-BFGS-B with logistic regression.
>
> What I did not is to use polr() to solve the proportional odds, and modify the source code for polr() by passing the lower bounds to the optim() and change the method to L-BFGS-B.
>
> Then I realized that polr() generate a start value for all coefficients with glm.fit, which can still start from negative.
>
> So my question is that does the start value having negative while the optimization has a lower bound as 0.00001. Does it matter?
>
> Or is there another way of implementation to solve proportional odds while forcing some coefficients as non-negative.
>
> Thanks so much!
>
> Zhao
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list