Displaying 20 results from an estimated 53 matches for "dmat".
Did you mean:
dma
2006 Jun 06
1
Problems using quadprog for solving quadratic programming problem
...nction doesn't lead the minimal "value" 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" sampl...
2008 Jul 15
1
manipulating (extracting) data from distance matrices
...ets from the
distance matrix in a simpler manner than my example code below?
##############
# ex_dist.R
# example for
# manipulating
# distance matrices
####################
set.seed<-12345
a<-sample(20:40, 10)
b<-sample(80:100, 10)
c<-sample(0:40, 10)
dat<-data.frame(a,b,c)
dat
dmat<-dist(dat, method="euclidean")
dmat
dmat[1:6] #vector that stores the distance matrix runs descending down
columns, left to right
#in a 10-element distance matrix, column lengths are 9,8,7,6....1
#get comparisons of rows 1:4 (from dat) ONLY
#top-left matrix will consist of top 3 of...
2010 Feb 19
1
Quadprog help
...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,0,0,0,0,0,0,-1,1,0,0,0,0,...
2003 Jun 02
1
Help with factorized argument in solve.QP
...orized" argument in solve.QP (part
of the quadprog library) to work as expected. The helpfile states that
when the factorized argument is set to TRUE, then the function requires
the inverse of a square-root factor of the Hessian instead of the
Hessian 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,...
2005 Jan 13
1
how to use solve.QP
...= bvec and [bLo=0 <= 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
...; is a Nx1 vector of the expected returns
and
\mu is a number, the postualted 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<...
2007 Mar 12
2
distance metrics
Hello:
Does anyone know if there exists a package that handles methods for [ for
dist objects?
I would like to access a dist object using matrix notation
e.g.
dMat = dist(x)
dMat[i,j]
Thanks in advance to anyone who can point me in the right direction.
[[alternative HTML version deleted]]
2009 Feb 16
2
solve.QP with box and equality constraints
...traints 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.
################
#examples below
################
library(quadprog)
#pai...
2010 Dec 04
1
Quadratic programming with semi-definite matrix
Hello.
I'm trying to solve a quadratic programming problem of the form min
||Hx - y||^2 s.t. x >= 0 and x <= t using solve.QP in the quadprog
package but I'm having problems with Dmat not being positive definite,
which is kinda okay since I expect it to be numerically semi-definite
in most cases. As far as I'm aware the problem arises because the
Goldfarb and Idnani method first solves the unconstrained problem
requiring a positive definite matrix. Are there any (fast) packa...
2014 Oct 07
0
QCQP Optimization
...I have been reading the
documentation and it seems like all the examples use equations instead of
vector manipulation. All of my parameters are vectors and matrices and they
can be quite large. Here is my problem:
X<-([Cf]+[H])%*%[A]
Y<-([Cf]+[H]-[R])%*%[B]I want to find H that minimizes Y%*%Dmat%*%t(Y) for a
given value of X%*%Dmat%*%t(X)
Cf, R, A, Dmat and B are matrices of constants.
The values for H sohould be between 0 and 1.
Is it possible to use Rsolnp to find the vector H even though the input
functions will all return other vectors?
--
View this message in context: http://r....
2007 Dec 22
1
using solve.qp without a quadratic term
...( function is in the quadprog package ) and the code is below. ( I'm not even sure there if there is a reasonable solution because I made the problem up ).
But, when I try to use solve.QP to solve it, I get the error that D in the quadratic function is not positive
definite. This is because Dmat is zero
because I don't have a quadratic term in my
objective function. So, I was wondering if
it was possible to use solve.QP when there isn't
a quadratic term in the objective function.
I imagine that there are other functions in R that can be used but I would like to use solve.QP beca...
2002 Jun 27
1
Building from a source-code library under windows
...*/
break;
case DLL_PROCESS_DETACH:
/* clean-up code here */
break;
}
return(TRUE);
}
#endif
void
nlme_two_comp_zero_CI_lag (long int *norow, double *maxoorder, double
*OMAT,
long int *ndrow, double *maxdorder, double *DMAT,
long int *logparam, long int *logresp, double *Resp)
{
long int i, j, No = *norow, Nd = *ndrow, LogParam = *logparam, LogResp =
*logresp;
double Tdiff, a, b, k21, origReset, counterDose, id, T1, constReseti,
constResetj,
MaxOORDER = *maxoorder, MaxDORDER = *maxdorder,
*OTime, *ITI...
2007 Jul 02
0
relocation error in grDevices.so
...talling R I downloaded and installed the
contributed quadprog library. I ran this simple solver example 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(&quo...
2012 Apr 25
2
comparison of bivariate normal distributions
...code example:
########################################
library(mvtnorm)
c<-data.frame(rnorm(1000,5,sd=1),rnorm(1000,6,sd=1))
c2<-data.frame(rnorm(1000,10,sd=2),rnorm(1000,7,sd=1))
xx=seq(0,20,0.1)
yy=seq(0,20,0.1)
xmult=cbind(rep(yy,201),rep(xx,each=201))
dens=dmvnorm(xmult,mean(c),cov(c))
dmat=matrix(dens,ncol=length(yy),nrow=length(xx),byrow=F)
dens2=dmvnorm(xmult,mean(c2),cov(c2))
dmat2=matrix(dens2,ncol=length(yy),nrow=length(xx),byrow=F)
contour(xx,yy,dmat,lwd=2)
contour(xx,yy,dmat2,lwd=2,add=T)
##############################################
Is their an easy way to do this (maybe w...
2010 Dec 06
1
use pcls to solve least square fitting with constraints
Hi,
I have a least square fitting problem with linear inequality
constraints. pcls seems capable of solving it so I tried it,
unfortunately, it is stuck with the following error:
> M <- list()
> M$y = Dmat[,1]
> M$X = Cmat
> M$Ain = as.matrix(Amat)
> M$bin = rep(0, dim(Amat)[1])
> M$p=qr.solve(as.matrix(Cmat), Dmat[,1])
> M$w = rep(1, length(M$y))
> M$C = matrix(0,0,0)
> p<-pcls(M)
Error in t(qr.qty(qra, t(M$X))[(j + 1):k, ]) :
error in evaluating the argument 'x' in...
2003 Apr 03
2
Matrix eigenvectors in R and MatLab
...7565 -0.33015962 0.09136359 -5.426254 -0.8201206
[5,] -0.68977432 0.01977374 0.61772506 3.751978 0.4348802
%Matlab Matrix
PA9900 =[11/24 10/53 0/1 0/1 29/43 ;1/24 27/53 0/1 0/1 13/43 ;14/24
178/53 146/244 17/23 15/43 ;2/24 4/53 0/1 2/23 2/43 ;4/24 58/53 26/244
0/1 5/43]
%MatLab-syntax
[wmat,dmat]=eig(mat)
%MatLab-output
wmat =
-0.2250 0.4330 -0.4998 -0.1795 -0.1854
-0.1083 0.1771 0.1599 -0.0614 -0.0583
-0.9403 -0.7191 -0.8457 0.9617 0.9708
-0.0327 -0.0752 -0.0967 -0.1750 -0.1160
-0.2289 -0.5083 0.0058 0.0928 0.0802
dmat =...
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
2007 Dec 18
4
accessing dimension names
I have a matrix y:
> dimnames(y)
$x93
[1] "1" "2"
$x94
[1] "0" "1" "2"
.................. so on (there are other dimensions as well)
I need to access a particular dimension, but a random mechanism tells me
which dimension it would. So, sometimes I might need to access
dimnames(y)$x93, some other time it would be dimnames(y)$x94.. and so
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]]
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