search for: amat

Displaying 20 results from an estimated 57 matches for "amat".

Did you mean: ama
2005 Jan 13
1
how to use solve.QP
...bLo=0 <= w <= 1=bUp Cov <- var(S) mu <- apply(S, 2, mean) mu.target <- 0.1 #subject to cLo <= A <= cUp and bLo=0 <= b <= 1=bUp A <- rbind(1,mu) cLo <- c(1, mu.target) cUp <- c(1, Inf) bLo <- rep(0, n) bUp <- rep(1, n) #I convert [cLo <= A <= cUp] to Amat >= 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...
2007 Sep 03
2
The quadprog package
...g) 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 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...
2008 Aug 05
1
Fix for nls bug???
...g nls. I think it may be a restriction in the applicability of nls and I may have found a fix, but I've been wrong before. This example is simplified to the essentials. My real application is much more complicated. Take a function of matrix 'x' with additional arguments: matrix 'aMat' whose values are _not_ to be determined by nls vector 'Coeffs' whose vales _are_ to be determined. For simplicity, this isn't a selfStart function with an 'initial' attribute, but that doesn't change things. Myfunc<-function(x, aMat, Coeffs) { # # result = quadrati...
2009 Feb 16
2
solve.QP with box and equality constraints
...l periods from aggregate data using restricted least squares. I seem to be making headway using solve.QP(quadprog) as the unrestricted solution matches the example I am following, and I can specify simple equality and inequality constraints. However, I cannot correctly specify a constraint matrix (Amat) with box constraints per cell and equality constraints that span multiple cells. Namely the solution matrix I am aiming for needs to respect the following conditions: - each row must sum to 1 - each cell must >= 0 - each cell must <= 1 I understand the general principle of creating bo...
2003 Jun 02
1
Help with factorized argument in solve.QP
...en 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 would have expected that...
2011 May 11
1
Problem with constrained optimization with maxBFGS
...ar all, I need to maximize the v: v= D' W D D is a column vector ( n , 1) W is a given matrix (n, n) subject to: sum D= 1 (BTW, n is less than 300) I´ve tried to use maxBFGS, as follows: ##################################### objectiveFunction<-function(x) { return(t(D)%*%W%*%D) } Amat<-diag(nrow(D)) Amat<-rbind((rep(-1, nrow(D))), Amat) bvec<-matrix( c(0), nrow(D)+1, 1) bvec[1,1]<-c(1) startValues=rep(1/nrow(D),nrow(D)) #Istart value is homogeneous distribution res <<- maxBFGS(objectiveFunction, start=startValues, constraints=list(ineqA=Amat, ineqB=bvec)) #####...
2006 Jun 06
1
Problems using quadprog for solving quadratic programming problem
...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[lower.tri(Dmatj)]<--2 Dm...
2005 Nov 29
1
Constraints in Quadprog
...9;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, Sergue...
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
2013 Mar 15
1
quadprog issues---how to define the constriants
...question: w = arg min 0.5*w'Mw - w'N s. t. sum(w) = 1; w>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&quot...
2006 Mar 18
1
listing nodes in paths
Hi All, I have the following adjacency matrix for a directed graph: [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 0 0 0 0 0 0 0 0 [2,] 0 0 0 0 0 0 0 0 [3,] 1 0 0 0 0 0 0 0 [4,] 0 0 1 0 0 0 0 0 [5,] 0 0 1 0 0 0 0 0 [6,] 1 1 0 0 0 0 0 0 [7,] 0 0
2007 Dec 22
1
using solve.qp without a quadratic term
...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)
2010 Feb 19
1
Quadprog help
...jective 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, 0,0,0,0,0,0,0,-1,0,0,0,1,0,0,0,0,0,0,0, 0,0,0,0,-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,-1,0,0,0,0,...
2012 Mar 16
1
quadprog error?
...act Berwin A. 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,...
2007 Jul 02
0
relocation error in grDevices.so
...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 rpy.r.assign("bvec", bvec) result = rpy.r("solve.QP(Dmat, dvec, Amat, bvec=bvec)&quo...
2005 Dec 14
6
mysql connection problems
Hi hi i have a problem trying to connect to the mysql database when I do a rake it says: Access denied for user: ''@localhost'' to database '''' My database.yml file is fine Any ideas why this is happening -- Posted via http://www.ruby-forum.com/.
2010 Dec 04
1
Quadratic programming with semi-definite matrix
...re 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
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 selecting a method for function 't' Af...
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 definition? Regards,...
2012 Jul 12
1
SVAR Restriction on AB-model
Hello! I'm doing a svar and when I make the estimation the next error message appears: In SVAR(x, Amat = amat, Bmat = bmat, start = NULL, max.iter = 1000, : The AB-model is just identified. No test possible. Could you help me to interpret it please. Also I have the identification assumption that one of my shocks is exogenous relative to the contemporaneous values of the other variables in the S...