search for: meq

Displaying 19 results from an estimated 19 matches for "meq".

Did you mean: me
2011 May 30
0
definition of meq at spg
...0)),c(rep(0,10)),c(rep(0,2),1,rep(0,7)), c(rep(0,3),1,rep(0,6)),c(rep(0,10)),c(rep(0,10)), c(rep(0,6),1,rep(0,3)),c(rep(0,7),1,rep(0,2)), c(rep(0,8),1,rep(0,1)),c(rep(0,9),1,rep(0,0)), c(rep(0,8),1,rep(0,1)),c(rep(0,9),1,rep(0,0)), c(rep(0,8),1,1)),ncol=10) b<-c(rep(0,4),rep(0,4),0,0,-1,-1,-1) meq<-c(seq(1:8),13) #1:8 &13 condition is an equality Although spg gives "Successful convergence" it also gives the message: There were 50 or more warnings (use warnings() to see the first 50) Warning messages: 1: In if (meq > 0 | any(b - c(A %*% par) > 0)) { ... : the condi...
2007 Sep 21
1
Is it solve.QP or is it me?
...,] 1 1 -1 0 0 0 0 0 0 0 [2,] -1 1 0 1 0 0 0 0 0 0 [3,] 1 1 0 0 -1 0 0 0 0 0 [4,] -1 1 0 0 0 1 0 0 0 0 [5,] 1 1 0 0 0 0 -1 0 0 0 [6,] -1 1 0 0 0 0 0 1 0 0 [7,] 1 1 0 0 0 0 0 0 -1 0 [8,] -1 1 0 0 0 0 0 0 0 1 >bv8 [1] 1 1 -1 0 -1 0 -1 0 -1 0 >meq [1] 2 >liSM8<-solve.QP(cm8,dv8,Am8,bv8,meq) >liSM8$solution [1] 2.500000e-01 2.858899e-53 2.500000e-01 0.000000e+00 2.500000e-01 0.000000e+00 2.500000e-01 1.387779e-17 >cma [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] 1 0 0 0 0 0 0 0 0 0...
2012 Mar 16
1
quadprog error?
.... Turlach <Berwin.Turlach at gmail.com> (maintainer for quadprog package) a week ago, with no success. ############################################################## load(file='quadprog.Rdata') # solve QP using quadprog require(quadprog) sol = solve.QP(Dmat, dvec, Amat, bvec, meq) x = sol$solution check = x %*% Amat - bvec # for some reason last equality constraint is violated round(check[1:meq], 4) # solve QP using kernlab require(kernlab) n = nrow(Amat) sv = ipop(c = matrix(dvec), H = Dmat, A = t(Amat[,1:meq]), b = bvec[1:meq], l = rep(-1000, n), u =...
2013 Mar 15
1
quadprog issues---how to define the constriants
...>0 note: w is weight vector, each w_i must >=0, and the sum of w =1. Here is my R code: A <-matrix(c(2.26,1.26,1.12,1.12,2.27,1.13,1.12,1.13,2.2),3,3); B <- c(0.007459281,0.007448885,0.007447850); M <-nrow(A); Amat <- cbind(rep(1,M), diag(M)); bvec <- c(1,rep(0,M)) ; meq <- 1; min <- solve.QP(Dmat=A,dvec=B,Amat=Amat,bvec=bvec,meq=meq) init_prior.weig <-min$solution; cat("weight = ",init_prior.weig,"\n" ) My question is: When I tried "big" matrix A and B, I get some negative weights. I think I already put th...
2007 Sep 03
2
The quadprog package
...ngegeben werden dvec mu<-0 # (in Mio. €) bvec<-c(1,mu,matrix(0,7,1)) # muss als Spaltenvektor eingegeben werden bvec mu_r<-c(19.7,33.0,0.0,49.7, 82.5, 39.0,11.8) Amat<-matrix(c(matrix(1,1,7),7*mu_r,diag(1,7,7)),9,7,byrow=T) # muss als Matrix angegeben werden, wie sie wirklich ist Amat meq<-2 loesung<-solve.QP(Dmat,dvec,Amat=t(Amat),bvec=bvec,meq=2) loesung # Überprüfen, ob System richtig gelöst wurde loesung$solution %*% mu_r sum(loesung$solution) for (i in 1:7){ a<-loesung$solution[i]>=0 print(a) } Thanks in advance for your answers. ______________________________...
2009 Feb 16
2
solve.QP with box and equality constraints
...nt matrix ( http://tolstoy.newcastle.edu.au/R/help/05/10/14251.html), but when I pass this expanded constraint matrix to solve.QP it complains that Amat and dvec are incompatible. How should I expand dvec (and consequently Dmat) to accomodate the larger Amat? Moreover, I am unclear how to apply the meq equality constraint across more than one cell (i.e. rows summing to one) although I have attempted a guess below. Any help warmly received. Selwyn. ################ #examples below ################ library(quadprog) #pairs of population values over time mat = cbind( cal = c(12988,13408,13834,1...
2005 Jan 13
1
how to use solve.QP
...1, mu.target, Inf, bLo, -bUp) zMat <- matrix(rep(0,2*n*n),ncol=n, nrow=n*2) zMat[,1] <- c(rep(1,n), rep(-1,n)) Amat <- t(rbind(Amat, zMat)) #So I set Dmat=Cov and set dvec=0 Dmat=Cov dvec=rep(0, nrow(Amat)) #The first two rows of Amat should be equality constraints (so weights sum to 1) meq <- 2 sol <- solve.QP(Dmat=Dmat, dvec=dvec, Amat=Amat, bvec=bvec, meq) sol
2003 Aug 24
1
regression constraints (again)
...ve read the archive and have set the problem up with solve.QP and just the non-negativity constraints along the lines of: y as the data vector X as the design matrix D <- t(X) %*% X d <- t(t(y) %*% X) A <- diag(ncol(X)) b <- rep(0,ncol(X)) fit <- solve.QP(D=D,d=d,A=t(A),b=b,meq=0) (as per Gardar Johannesson '01) When I try to add the extra constraint that sum(weights)=1 I get errors owing to incompatibility of matrices. I add the constraint by putting an extra column of all ones to A and setting meq=1. I can work round it I think, by using an intercept and usin...
2018 May 05
1
adding overall constraint in optim()
...can use the projectLinear argument in BB::spg to optimize with linear equality/inequality constraints. Here is how you implement the constraint that all parameters sum to 1. require(BB) spg(par=p0, fn=myFn, project="projectLinear", projectArgs=list(A=matrix(1, 1, length(p0)), b=1, meq=1)) Hope this is helpful, Ravi [[alternative HTML version deleted]]
2005 Nov 29
1
Constraints in Quadprog
...ifficulty figuring out how to implement the following set of constraints in Quadprog: 1). x1+x2+x3+x4=a1 2). x1+x2+x5+x6=a2 3). x1+x3+x5+x7=a3 4). x1+x2=b1 5). x1+x3=b2 6). x1+x5=b3 for the problem: MIN (x1-c1)2+(x2-c2)2+...+(x8-c8)2. As far a I understand, "solve.QP(Dmat, dvec, Amat, bvec, meq=0, factorized=FALSE)" reads contraints using an element-by-element multiplication, i.e. Amat'*x, not using the matrix-product, i.e. Amat'%*%x, required for the sums on the left-hand-side of 1-6). I would very much appreciate a suggestion on this problem. Thank you, Serguei Kaniovski
2008 Mar 03
2
Constrained regression
Dear list members, I am trying to get information on how to fit a linear regression with constrained parameters. Specifically, I have 8 predictors , their coeffiecients should all be non-negative and add up to 1. I understand it is a quadratic programming problem but I have no experience in the subject. I searched the archives but the results were inconclusive. Could someone provide suggestions
2006 Jun 06
1
Problems using quadprog for solving quadratic programming problem
...(Dmat) Amat<-matrix(ncol=n,nrow=k*n,0) ind<-seq(1,((k-1)*n+1),n) for(i in 1:n){ Amat[(ind+(i-1)),i]<-1 } Amat<-cbind(Amat,diag(n*k),-diag(n*k)) print(Amat) bvec<-c(rep(1,n),c(0.1,0.2,0.8,0.6,-0.2,-0.4,-0.9,-0.8)) print(bvec) dvec=rep(0,(n*k)) erg<-solve.QP(Dmat,dvec,Amat,bvec,meq=n) print(erg) erg<-erg$solution -dvec%*%erg+.5*erg^T%*%Dmat%*%erg
2010 Oct 31
2
Constrained Regression
Hello everyone, I have 3 variables Y, X1 and X2. Each variables lies between 0 and 1. I want to do a constrained regression such that a>0 and (1-a) >0 for the model: Y = a*X1 + (1-a)*X2 I tried the help on the constrained regression in R but I concede that it was not helpful. Any help is greatly appreciated -- Thanks, Jim. [[alternative HTML version deleted]]
2013 Apr 04
5
Help for bootstrapping‏
...orizon*(x-1)+1):(12*horizon*(x-1)+12*horizon),2])-1}Return<-cbind(TbillReturn,USReturn)MeanVec<-c(mean(TbillReturn),mean(USReturn))VCovMat<-cov(Return)#return(MeanVec, VCovMat) a<-c(1,1)a<-cbind(a, diag(1,2)) WtVec<-solve.QP(Dmat=VCovMat*2, dvec= MeanVec*lamda,Amat=a,bvec=c(1,0,0),meq=1) #return(MeanVec, VCovMat, WtVec$solution)return(WtVec$solution)} #Opt(OriData+1, 1, 5, 0) ##############################set.seed(4114)bs=1000 ###number of bootstrap samplesRegion<-5 ###Region indecies, check above.lamdaseq<-seq(0,1,.05) ###the lamda sequence. currently from 0...
2010 Jan 21
0
fPortfolio prob: maxreturnPortfolio() returns Na/NaN/Inf error
...I think, when it reaches the line optim = .Fortran("qpgen2", as.double(Dmat), dvec = as.double(dvec), as.integer(n), as.integer(n), sol = as.double(rep(0, n)), crval = as.double(0), as.double(Amat), as.double(bvec), as.integer(n), as.integer(q), as.integer(meq), iact = as.integer(rep(0, q)), nact = as.integer(0), iter = as.integer(rep(0, 2)), work = as.double(work), ierr = as.integer(0), PACKAGE = "quadprog") ...where I have highlighted the offending argument (8). Now, there is nothing unusual that I can see ab...
2001 Nov 20
0
Summary: non-negative least squares
...ar Johannesson wrote: You can always just use the quadratic programing library in R (quadprog). That is, if you have y as your data vector X as your design matrix Then do, D <- t(X) %*% X d <- t(t(y) %*% X) A <- diag(ncol(X)) b <- rep(0,ncol(X)) fit <- solve.QP(D=D,d=d,A=t(A),b=b,meq=0) and the solution is in fit$solution Good luck, Gardar Marcel Wolbers wrote: Hi Bob I use the routine below which uses library quadprog for non-negative least squares. The scaling (xscale, yscale) is in principle unnecessary; it's only there because there's a minor bug in the librar...
2009 Nov 04
3
Constrained Optimization
Hi All, I'm trying to do the following constrained optimization example. Maximize x1*(1-x1) + x2*(1-x2) + x3*(1-x3) s.t. x1 + x2 + x3 = 1 x1 >= 0 and x1 <= 1 x2 >= 0 and x2 <= 1 x3 >= 0 and x3 <= 1 which are the constraints. I'm expecting the answer x1=x2=x3 = 1/3. I tried the "constrOptim" function in R and I'm running into some issues. I first start off
2006 Oct 03
1
HP Toolbox kills Samba
...47X$CI,UC/=YA5^@)$"8[ 2 M,+)A5%H'P,B',6@/&-DPKH8U8.3#Z-=\(L"8`Z-1U@)&/HP>4TP',%JE!@JC M_,]=TNA<&+5J=A;6/S;#Z&+J>ZQ:[K5_;LF7KM[HJ_EY.=N[<U!>3 _.)\OE M[T7]#8_&QP^/GCW]QW[R(N6_JJ:SBS-G]I2_.WHT_N[PQ:.'^Y](KM;:/E^U MK7]Y.'[P].CP?P\?["=MEQ>3B\NV_UY>C-_,B_+>\_'C1\>'W[T3SIB[H_K_ M+D__5=Z3RM1]6N/T?^V7GI\5XS=O)N=[;:\:$>M__N'XZ,7X^/#^PW?-;S\= M/WYQ>'?T_?T?QC\</_Z?^R\.WZU^O__LZ-D_OC_Z\?G=T=>R[N_F#?\P0C;E MA:_&9V?+LGS=?*B:#C^+FAW/#P^?C!_\>+R_]F7;OJ\;WEG,YQ??_O&MJ/_[ M]J#YX^#D='9P,EF^^F5...
2008 Jun 30
4
Rebuild of kernel 2.6.9-67.0.20.EL failure
Hello list. I'm trying to rebuild the 2.6.9.67.0.20.EL kernel, but it fails even without modifications. How did I try it? Created a (non-root) build environment (not a mock ) Installed the kernel.scr.rpm and did a rpmbuild -ba --target=`uname -m` kernel-2.6.spec 2> prep-err.log | tee prep-out.log The build failed at the end: Processing files: kernel-xenU-devel-2.6.9-67.0.20.EL Checking