Hi Gregg, I thank you for for information about the function vglm()
However it appears that my constraints are a little different. My parameters have lower and upper bounds and also sum of the estimated coefficients should be equal to some predefined value. Other than that, there is no Intercept in my model. I am more concerned on how can I put the above sum constraint and no intercept in the model design. One way to impose that perhaps is to use some Penalty function to the log-likelihood function, but probably that would become too complex for this type of constraint. Also, I tried to look into the internal function vglm.fitter() to explore how log-likelihood has been constructed, however I could not see the code inside this function. Any further help would be appreciated. On Wed, Apr 9, 2025 at 12:33 AM Gregg Powell <g.a.pow...@protonmail.com> wrote: > > there are ways to implement constraints on parameter estimates in ordinal > logistic regression in R. Here are a few approaches: > > The rms package (Regression Modeling Strategies) by Frank Harrell offers the > lrm function which can handle constraints through its penalty parameter, > though it's primarily designed for regularization. > For more flexible constraints, you can use the constrOptim or optim functions > from base R along with a custom likelihood function for ordinal logistic > regression. > The VGAM package provides the vglm function with family cumulative that can > handle certain types of constraints. > For Bayesian approaches, you can use brms or rstan to impose informative > priors that effectively constrain parameters. > > Here's a simple example using the VGAM package: > > > library(VGAM) > > library(foreign) > > > > # Load data > > dat <- foreign::read.dta("https://stats.idre.ucla.edu/stat/data/ologit.dta") > > > > > # Unconstrained model (for comparison) > > model_unconstrained <- vglm(apply ~ pared + public + gpa, > > > family = cumulative(parallel = TRUE), > > data = dat) > > summary(model_unconstrained) > > > > # Constrained model (example: constraining pared coefficient to be positive) > > # This uses the "constraint" matrix approach > > constraint <- rbind( > > c(0, 1, 0, 0), # This row corresponds to pared coefficient > > c(0, 0, 0, 0), # These rows do nothing (identity constraints for other > > parameters) > > c(0, 0, 0, 0) > > ) > > > model_constrained <- vglm(apply ~ pared + public + gpa, > > > family = cumulative(parallel = TRUE), > > constraints = constraint, > > data = dat) > > summary(model_constrained) > > > For more complex constraints, you might need to work with optimization > functions directly. > > > r/ > Gregg > > > > On Tuesday, April 8th, 2025 at 11:20 AM, Christofer Bogaso > <bogaso.christo...@gmail.com> wrote: > > > > > > > > > Hi, > > > > > I have below fit with ordinal logistic regression > > > > > dat = foreign::read.dta("https://stats.idre.ucla.edu/stat/data/ologit.dta") > > > > > summary(MASS::polr(formula = apply ~ pared + public + gpa, data = dat)) > > > > > However, instead of obtaining unconstrained estimates of model > > parameters, I would like to impose certain constraints on each of the > > model parameters, based on some non-sample information. > > > > > Is there any R function to estimate model coefficients with imposing > > some unser-defined constraints on the model parameters? > > > > > Any pointer will be very helpful. > > > > > ______________________________________________ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > https://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide https://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.