[R] Help with factorized argument in solve.QP

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon Jun 2 19:04:49 CEST 2003


"David S. Khabie-Zeitoune" <dave at mirabellafunds.com> writes:

> 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 x1$solution and x2$solution were the same (or
> numerically similar); however they are typically very different. Where
> am I going wrong...?

Hmmm. Could it be that it is assuming a *triangular* square root of
the matrix?

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list