Re: [R] Estimating regression with constraints in model coefficients

2025-04-21 Thread Jeff Newmiller via R-help
Logarithms are being referred to in two contexts here... log of likelihood, and log of domain variables. I just wanted to highlight that the latter has a surprisingly simple theoretical basis in optimization. If you have a function that you want to find an optimum of, but an input variable need

Re: [R] Estimating regression with constraints in model coefficients

2025-04-21 Thread Ben Bolker
Section 2 of the vignette for the ordinal package: https://cran.r-project.org/web/packages/ordinal/vignettes/clm_article.pdf gives a reasonably complete, if short, definition/discussion of the log-likelihood framework for ordinal models. It's probably also discussed in Venables and Ripley

Re: [R] Estimating regression with constraints in model coefficients

2025-04-21 Thread Christofer Bogaso
Hi Gregg, I am sincerely thankful for this workout. Could you please suggest any text book on how to create log-likelihood for an ordinal model like this? Most of my online search point me directly to some R function etc, but a theoretical discussion on this subject would be really helpful to con

Re: [R] Estimating regression with constraints in model coefficients

2025-04-21 Thread Gregg Powell via R-help
Christofer, Given the constraints you mentioned—bounded parameters, no intercept, and a sum constraint—you're outside the capabilities of most off-the-shelf ordinal logistic regression functions in R like vglm or polr. The most flexible recommendation at this point is to implement custom likel

Re: [R] Generate random vectors (continuous number) with a fixed sum

2025-04-21 Thread Rui Barradas
Hello, Inline. Às 16:08 de 21/04/2025, Rui Barradas escreveu: Às 15:27 de 21/04/2025, Brian Smith escreveu: Hi, There is a function called RandVec in the package Surrogate which can generate andom vectors (continuous number) with a fixed sum The help page of this function states that: a Th

Re: [R] Generate random vectors (continuous number) with a fixed sum

2025-04-21 Thread Rui Barradas
Às 15:27 de 21/04/2025, Brian Smith escreveu: Hi, There is a function called RandVec in the package Surrogate which can generate andom vectors (continuous number) with a fixed sum The help page of this function states that: a The function RandVec generates an n by m matrix x. Each of the m co

Re: [R] Generate random vectors (continuous number) with a fixed sum

2025-04-21 Thread Eric Berger
RandVec expects both a and b to be single numbers, not numeric vectors of length > 1. You could create pairs of (a,b) values and cycle through them. There are many ways to do that. Here is one example. (Note that using a=0.1, b=.2, s=1, n=2 is impossible to achieve, since two numbers bounded above

[R] Generate random vectors (continuous number) with a fixed sum

2025-04-21 Thread Brian Smith
Hi, There is a function called RandVec in the package Surrogate which can generate andom vectors (continuous number) with a fixed sum The help page of this function states that: a The function RandVec generates an n by m matrix x. Each of the m columns contain n random values lying in the inter

Re: [R] Estimating regression with constraints in model coefficients

2025-04-21 Thread J C Nash
It may be overkill, but package nlsr has function nlxb() that can handle various models and bound the parameters. Note that bounds can sometimes give weird results if the bounds and initial parameter guesses are such that the minimization of the sum of squares gets "stuck". JN On 2025-04-21 09:

Re: [R] Estimating regression with constraints in model coefficients

2025-04-21 Thread Christofer Bogaso
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 Intercep

Re: [R] Is it odd or not? about I() function

2025-04-21 Thread Hiroto Miyoshi
Dear R experts, Thank you all for your help. Now, I know that the ggplot is causing the issue and that setting the y=as.numeric(rslt_with_I) can fix the problem, that should suffice for now, since I am not an R expert. In addition, this time, I could learn that there is a class of "AsIs", and th