Re: [R] Quadratic programming

2020-09-24 Thread Maija Sirkjärvi
Thank you for giving me your time! The problem is the quadratic optimization part. Something goes wrong along the way. In C++ loops run from 0 and in R they run from 1, and I've tried to take that into account. Still I'm having hard time figuring out the mistake I make, cause I get a result from

Re: [R] Quadratic programming

2020-09-22 Thread Maija Sirkjärvi
) If that fails, then you'll need to produce a minimal reproducible > example. > > I strongly recommend that the R code matches the quadratic program, as > > closely as possible. > > > > > > On Mon, Sep 21, 2020 at 9:28 PM Maija Sirkjärvi > > wrote: >

Re: [R] Quadratic programming

2020-09-21 Thread Maija Sirkjärvi
dom shot in the dark, should bvec be -bvec? > > > > > > > > > On Mon, Sep 21, 2020 at 9:28 PM Maija Sirkjärvi > > > wrote: > > > > > > > > Hi! > > > > > > > > I was wondering if someone could help me out. I'm minimizing

[R] Quadratic programming

2020-09-21 Thread Maija Sirkjärvi
Hi! I was wondering if someone could help me out. I'm minimizing a following function: \begin{equation} $$\sum_{j=1}^{J}(m_{j} -\hat{m_{j}})^2,$$ \text{subject to} $$m_{j-1}\leq m_{j}-\delta_{1}$$ $$\frac{1}{Q_{j-1}-Q_{j-2}} (m_{j-2}-m_{j-1}) \leq \frac{1}{Q_{j}-Q_{j-1}}

[R] constraints are inconsistent, no solution!

2018-09-17 Thread Maija Sirkjärvi
Hi! I'm solving a quadratic programming problem with some constraints. The problem is the second set of Amat conditions, which seem to be inconsistent, but I cannot see why. Do you have any idea, what could be the problem? Thanks in advance for your help! Maija for(j in 1:J){ hs[j]

Re: [R] loop over matrix: subscript out of bounds

2018-08-08 Thread Maija Sirkjärvi
barra...@sapo.pt) kirjoitti: >> >> > Hello, >> > >> > If it is not running as you want it, you should say what went wrong. >> > Post the code that you have tried and the expected output, please. >> > (In fact, the lack of expected output was t

Re: [R] loop over matrix: subscript out of bounds

2018-08-08 Thread Maija Sirkjärvi
d and the expected output, please. > (In fact, the lack of expected output was the reason why my suggestion > was completely off target.) > > Rui Barradas > > On 07/08/2018 09:20, Maija Sirkjärvi wrote: > > Thanks, but I didn't quite get it. And I don't get it running as it &g

Re: [R] loop over matrix: subscript out of bounds

2018-08-07 Thread Maija Sirkjärvi
Thanks, but I didn't quite get it. And I don't get it running as it should. ti 7. elok. 2018 klo 10.47 Martin Maechler (maech...@stat.math.ethz.ch) kirjoitti: > > > Thanks for help! > > However, changing the index from i to j for the column vector changes the > > output. I would like the matrix

Re: [R] loop over matrix: subscript out of bounds

2018-08-07 Thread Maija Sirkjärvi
this helps, > > Rui Barradas > > Às 10:24 de 06/08/2018, Eric Berger escreveu: > > Both loops are on 'i', which is a bad idea. :-) > > Also myMatrix[i,i+1] will be out-of-bounds if i = ncol(myMatrix) > > > > > > On Mon, Aug 6, 2018 at 12:02 PM, Maija

[R] loop over matrix: subscript out of bounds

2018-08-06 Thread Maija Sirkjärvi
I have a basic for loop with a simple matrix. The code is doing what it is supposed to do, but I'm still wondering the error "subscript out of bounds". What would be a smoother way to code such a basic for loop? myMatrix <- matrix(0,5,12) for(i in 1:nrow(myMatrix)) { for(i in 1:ncol(myMatrix))

Re: [R] Fwd: Quadratic programming, for loop

2018-07-30 Thread Maija Sirkjärvi
for help! Maija pe 29. kesäk. 2018 klo 13.29 Berwin A Turlach (berwin.turl...@gmail.com) kirjoitti: > G'day Maija, > > On Wed, 27 Jun 2018 08:48:08 +0300 > Maija Sirkjärvi wrote: > > > Thanks for your reply! Unfortunately something is still wrong. > > > > After the t

Re: [R] Fwd: Quadratic programming, for loop

2018-06-26 Thread Maija Sirkjärvi
of length *J*, then b will be of length J too. I believe the length of dvec comes from the number of variables and the length of b from the number of constraints. In this case they are not equal. 2018-06-26 15:01 GMT+03:00 Berwin A Turlach : > G'day all, > > On Tue, 26 Jun 2018 11:16:55

Re: [R] Fwd: Quadratic programming, for loop

2018-06-26 Thread Maija Sirkjärvi
On Tue, Jun 26, 2018 at 11:16 AM, Maija Sirkjärvi < > maija.sirkja...@gmail.com> wrote: > >> Thanks for the reply! I got that figured out, but still have some problems >> with the quadratic programming. >> >> It seems that my Amat and dvec are incompatible.

Re: [R] Fwd: Quadratic programming, for loop

2018-06-26 Thread Maija Sirkjärvi
error message: you are trying to replace a matrix element > with a zero-length (i.e. unassigned) numeric value. Perhaps, in your mind, > you are mixing up the index of a vector element and its value? If you need > two zeros to start your vector, do something like > > R > Q <- c(

[R] Fwd: Quadratic programming, for loop

2018-06-13 Thread Maija Sirkjärvi
Hi! I have a quadratic optimization problem and I have some difficulties coding it with R. The math version of the problem looks like this: min sum(mj -mj^)^2 which goes from 1 to J st. mj-1 <= mj - delta1 1/(Qj-1 -Qj-2)(mj-2 -mj-1) <= 1/(Qj -Qj-1 ) (mj-1 - mj) -delta2 And I'm coding it like