Displaying 20 results from an estimated 35 matches for "dvec".
Did you mean:
bvec
2003 Jun 02
1
Help with factorized argument in solve.QP
...an itself. That is, when factorized=TRUE, the Dmat argument should
be a matrix R^(-1), such that the Hessian of the objective function is
t(R) %*% R.
I modified the example in the helpfile slightly to test this out:
R = matrix(rnorm(9),3,3)
R.inv = solve(R)
Dmat = t(R) %*% R
dvec = c(0,5,0)
Amat = matrix(c(-4,-3,0,2,1,0,0,-2,1),3,3)
bvec = c(-8,2,0)
x1 = solve.QP(Dmat=Dmat, dvec=dvec, Amat=Amat, bvec=bvec,
factorized=FALSE)
x2 = solve.QP(Dmat=R.inv, dvec=dvec, Amat=Amat, bvec=bvec,
factorized=TRUE)
print(x1$solution)
print(x2$solution)
I wou...
2009 Feb 16
2
solve.QP with box and equality constraints
...t <= 1
I understand the general principle of creating box constraints by creating
pairs of positive and negative values within the constraint 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.
#######...
2005 Jan 13
1
how to use solve.QP
...<= w #<=1=bUp] to
Amat <- rbind(-1, 1, -mu, mu)
dim(bLo) <- c(n,1)
dim(bUp) <- c(n,1)
bvec <- rbind(-1, 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
2007 Sep 03
2
The quadprog package
...lted return of the investor
I've done the following code but it doesn't make what I want it to do. The weights aren't all positive and the \mu isn't reached. What's wrong with my code?
Require(quadprog)
Dmat<-diag(1,7,7)
# muss als quadratische Matrix eingegeben werden
Dmat
dvec<-matrix(0,7,1) # muss als Spaltenvektor eingegeben 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 Matri...
2006 Jun 06
1
Problems using quadprog for solving quadratic programming problem
...ot; calculated by solve.QP
I would be very happy, if anyone could help and tell me, where's my mistake. Thank you very much. Fabian
My R-code also containing the sampel of quadprog starts here:
#sample from quadprog package
library(quadprog)
Dmat <- matrix(0,3,3)
diag(Dmat) <- 1
dvec <- c(0,5,0)
Amat <- matrix(c(-4,-3,0,2,1,0,0,-2,1),3,3)
bvec <- c(-8,2,0)
erg<-solve.QP(Dmat,dvec,Amat,bvec=bvec)
print(erg)
erg<-erg$solution
-dvec%*%erg+.5*erg^T%*%Dmat%*%erg
# my "non working" sample
n<-2
k<-2
Dmatj<-diag((n-1),n)
Dmatj[l...
2013 Feb 21
0
About multivariate GARCH: DVEC and BEKK
Dear All,
I attempted to fit a DVEC and a BEKK multivariate GARCH model, but am
wondering which package to use.
1. I tried to use "rmgarch" package in R, but I couldn't find the
subroutines for DVEC and BEKK.
2. I tried to find "rmgarch" package of R, which is not located on the
official R site. This is...
2010 Feb 19
1
Quadprog help
...*P6^2,
Subject to a set of constrains including not only the variables P1, P2, P3,
P4, P5, P6, but also the variables X1, X2,X3,X4,X5,X6,X7,X8,X9.
As the set of variables X's are not affecting the objective function, I
assume that I have to enter them as zero's in the vector "dvec" and the
matrix "Dmat".
My program states as:
mat<-matrix(0,15,15)
diag(Dmat)<-c(10,5,8,10,20,10,0,0,0,0,0,0,0,0,0)
dvec<- c(-200,-100,-160,-50,-50,-50,0,0,0,0,0,0,0,0,0)
Amat<- matrix(c(-1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,1,
0,0,0,0,0,0,0...
2007 Jul 02
0
relocation error in grDevices.so
...mple using
Python+rpy which works (well, except for some R error I haven't
figured out yet) in the old installation:
import numpy
import rpy
rpy.r("library(quadprog)")
Dmat = numpy.identity(3, numpy.float_)
print Dmat
rpy.r.assign("Dmat", Dmat)
dvec = numpy.array([0,5,0], numpy.float_)
print dvec
rpy.r.assign("dvec", dvec)
Amat = numpy.array([[-4,-3,0], [2,1,0], [0,-2,1]], numpy.float_)
print Amat
rpy.r.assign("Amat", Amat.transpose())
bvec = numpy.array([-8,2,0], numpy.float_)
print bvec
r...
2010 Dec 04
1
Quadratic programming with semi-definite matrix
...matrix. Are there any (fast) packages
that allows me to do QP with (large) semidefinite matrices?
Example:
t <- 100
y <- signalConvNoisy[1,]
D <- crossprod(H,H)
d <- crossprod(H,y)
A <- cbind(rep(-1, nrow(H)), diag(ncol(H)))
b0 <- c(t, rep(0, ncol(H)))
sol <- solve.QP(Dmat=D, dvec = d, Amat = A, bvec = b0)$solution
Error in solve.QP(Dmat = D, dvec = d, Amat = A, bvec = b0) :
matrix D in quadratic function is not positive definite!
Thanks in advance,
Andreas Jensen
2008 May 08
0
solve.QP() error
I got following error while I was using solve.QP() in my problem:
> Dmat = matrix(c(0.0001741, 0.0001280, 0.0001280, 0.0002570), nrow=2)
> dvec = t(c(0,0))
> Amat = matrix(c(-1,1,0,-1,0, 1,0,1,0,-1), nrow=5)
> bvec = c(-20000, 1, 1, -50000, -50000)
> solve.QP(Dmat,dvec,Amat,bvec=bvec)
Error in solve.QP(Dmat, dvec, Amat, bvec = bvec) :
Amat and dvec are incompatible!
>
Can anyone tell me where is the error in my defin...
2010 Jan 21
0
fPortfolio prob: maxreturnPortfolio() returns Na/NaN/Inf error
...subject to setTargetRisk(myspec)=0.08 using only constraints="LongOnly"
I can run feasiblePortfolio() using a spec file that specifies the weights, and it works fine.
When I run maxreturnPortfolio(mydata,myspec,"LongOnly"), however, I get
Error in .rquadprog(Dmat = args$Dmat, dvec = args$dvec, Amat = args$Amat, :
NA/NaN/Inf in foreign function call (arg 8)
Troubleshooting, it appears to be occurring in the routine eqsumWConstraints within .rquadprogArguments. Specifically, when that routine calls
ceq <- c(Return = targetReturn, Budget = -1)
it produces
> ceq
Retu...
2007 Dec 22
1
using solve.qp without a quadratic term
...to implement hundreds of constraints just solve.QP that I am unaware of ? Thanks for any suggestions.
# IN THE CODE BELOW, WE MINIMIZE
# -3*b1 + 4*b2 + 6*b3
# SUBJECT TO
# b1 + b2 + b3 >=0
# -(b1 b2 + b3) >= 0
# IE : b1 + b2 + b3 = 0.
Dmat <- matrix(0,3,3) # QUADRATIC TERM
dvec <- c(-3,4,6) # LINEAR TERM
Amat <- matrix(c(1,-1,0,1,-1,0,1,-1,0),3,3)
#print(Amat)
bvec = c(0,0,0) # THIRD ZERO IS SAME AS NO CONSTRAINT
result <- solve.QP(Dmat, dvec, Amat)
2018 Mar 05
0
Interpret List Label as Date from Quantmod getOptionChain
...6" "2018-04-13" "2018-04-20" "2018-05-18"
[8] "2018-06-15" "2018-08-17" "2018-09-21" "2018-10-19" "2018-11-16" "2019-01-18" "2019-06-21"
[15] "2020-01-17" "2020-06-19"
R> dvec <- anydate(names(aapl_total)) # helper variable
R> ind <- dvec >= anydate("2018-04-01") & dvec <= anydate("2018-04-30") # one example
R> ind
[1] FALSE FALSE FALSE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
R...
2011 Nov 21
0
Suggested improvement for src/library/base/man/qraux.Rd
...ckage, http://www.R-project.org<http://www.r-project.org/>
% Copyright 1995-2007 R Core Development Team
% Distributed under GPL 2 or later
\name{QR.Auxiliaries}
\title{Reconstruct the Q, R, or X Matrices from a QR Object}
\usage{
qr.X(qr, complete = FALSE, ncol =)
qr.Q(qr, complete = FALSE, Dvec =)
qr.R(qr, complete = FALSE)
}
\alias{qr.X}
\alias{qr.Q}
\alias{qr.R}
\arguments{
\item{qr}{object representing a QR decomposition. This will
typically have come from a previous call to \code{\link{qr}} or
\code{\link{lsfit}}.}
\item{complete}{logical expression of length 1. Indicates wh...
2018 Mar 05
2
Interpret List Label as Date from Quantmod getOptionChain
Hi Dirk,
Thanks for your note.
I understand that expiry dates are the dates that the option expires, so I don't think that I am confused about that (although the upper limits of one's confusion is difficult to accurately estimate).
My lack of clarity come from treating those "dates" as actual dates as opposed to strings, which one could reasonably interpret them to be from
2009 Nov 11
1
Help with fPortfolio
...he efficientPortfolio function
even though I'm setting the target return to the mean of the TargetReturn I
obtain from the portfolio object created by the feasiblePortfolio function.
First Error:
Error: targetReturn >= min(mu) is not TRUE
Second Error:
Error in .rquadprog(Dmat = args$Dmat, dvec = args$dvec, Amat = args$Amat, :
NA/NaN/Inf in foreign function call (arg 8)
I'm using a timeSeries created from daily stock prices of selected stocks on
the Bombay Sensex. My timeSeries is of the following format
date stock1 stock2 stock3
I don't understand why I'm getting these...
2004 Sep 01
0
not positive definite D matrix in quadprog
...s)
#now all eigenvalues are positive:
D.values.new <-
eigen(D.vectors%*%D.quad%*%ginv(D.vectors),only.values=F)$values
D.values.new
[1] 4.609489e+04 2.458166e+03 8.232288e+01 1.961199e+00 5.976441e-01
[6] 2.810968e-01 1.253140e-09 1.428534e-12
Dmat <- D.vectors%*%D.quad%*%ginv(D.vectors)
dvec <-
-c(-2910.533769,-2905.609008,-3012.223863,-16274.97455,-17222.46423,-18380.6
391,-357.8878464,-379.6371849)
#this ensures that coefficients are positive:
Amat <- matrix(0,8,8)
diag(Amat) <- 1
bvec <- rep(0,8)
#it says D is not positive definite ...
solve.QP(Dmat,dvec,Amat,bvec=...
2005 Nov 29
1
Constraints in Quadprog
I'm having difficulty 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,...
2007 Dec 06
1
Solve.QP
Hi there,
I have a major problem (major for me that is) with solve.QP and I'm new at this. You see, to solve my quadratic program I need to have the lagrange multipliers after each iteration. Solve.QP gives me the solution, the unconstrained solution aswell as the optimal value. Does anybody have an idea for how I could extract the multipliers?
Thanx,
Serge
"Beatus qui prodest quibus
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