[R] QP.solve, QPmat, constraint matrix, and positive definite

2008-04-10 Thread jpolo
hello all,

i'm trying to use QPmat, from the popbio package. it appears to be based
on solve.QP and is intended for making a population projection matrix.
QPmat asks for: nout, A time series of population vectors and C, C
constraint matrix, (with two more vectors, b and nonzero). i believe the
relevant code from QPmat is:

function (nout, C, b, nonzero)
{
if (!"quadprog" %in% (.packages())) {
library(quadprog)
}
n <- dim(nout)
z <- nout[, 2:n[2]]
z <- matrix(z, n[1] * (n[2] - 1), 1)
M <- c()
for (i in 1:(n[2] - 1)) {
N <- kronecker(t(nout[, i]), diag(n[1]))
m <- N[, nonzero]
M <- rbind(M, m)
}
G <- t(M) %*% M
f <- t(M) %*% z
res <- solve.QP(G, f, -t(C), -b)

i'm receiving the error
"Error in solve.QP(G, f, -t(C), -b) :
  matrix D in quadratic function is not positive definite!"

solve.QP documentation says that Dmat goes into the place that is referred
to in the code as G. i've two matrices. nout is 31x3 and all elements are
0 or positive. my C matrix is 31 x 31 and has a -1 running diagonal from
the upper left to the lower right, with everything else 0. i'm somewhat
confused by what matrix or element is being multiplied as it leads up to G
and all i can guess is that i didn't construct the C matrix correctly. how
would i do that?

sorry if i have too much info or am missing something. thanks for your time.

john

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] QP.solve, QPmat, constraint matrix, and positive definite

2008-04-10 Thread jpolo
hello all,

i'm trying to use QPmat, from the popbio package. it appears to be based
on solve.QP and is intended for making a population projection matrix.
QPmat asks for: nout, A time series of population vectors and C, C
constraint matrix, (with two more vectors, b and nonzero). i believe the
relevant code from QPmat is:

function (nout, C, b, nonzero)
{
if (!"quadprog" %in% (.packages())) {
library(quadprog)
}
n <- dim(nout)
z <- nout[, 2:n[2]]
z <- matrix(z, n[1] * (n[2] - 1), 1)
M <- c()
for (i in 1:(n[2] - 1)) {
N <- kronecker(t(nout[, i]), diag(n[1]))
m <- N[, nonzero]
M <- rbind(M, m)
}
G <- t(M) %*% M
f <- t(M) %*% z
res <- solve.QP(G, f, -t(C), -b)

i'm receiving the error
"Error in solve.QP(G, f, -t(C), -b) :
  matrix D in quadratic function is not positive definite!"

solve.QP documentation says that Dmat goes into the place that is referred
to in the code as G. i've two matrices. nout is 31x3 and all elements are
0 or positive. my C matrix is 31 x 31 and has a -1 running diagonal from
the upper left to the lower right, with everything else 0. i'm somewhat
confused by what matrix or element is being multiplied as it leads up to G
and all i can guess is that i didn't construct the C matrix correctly. how
would i do that?

sorry if i have too much info or am missing something. thanks for your time.

john

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] QP.solve, QPmat, constraint matrix, and positive definite

2008-04-11 Thread jpolo
i found the posdefify, nearcor, and nearPD functions, but can't get things
to work. when i tried nearPd, it gave me an dpoMatrix, but i don't know if
it would have worked because it said:
"31 x 31 Matrix of class "dpoMatrix" "
right between $mat and the actual matrix and i don't know how to cut that
out.

i'm not sure i'm even putting the right variables in the right places,
relative to the functions' respective requirements.

sorry about double-posting as well. the web interface for school's email
uses some lousy jsp that times out in the middle of emails and whatnot.


john

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] installing and using a package

2008-01-10 Thread jpolo
i'm trying to learn R. i have no programing experience. i tried to add on
a package and just picked "yags". i can't get it to work or get any help.

---
> install.packages("yags")
Warning in install.packages("yags") :
  argument 'lib' is missing: using 'C:\Documents and Settings\j\My
Documents/R/win-library/2.6'
trying URL
'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.6/yags_4.0-2.zip'
Content type 'application/zip' length 183779 bytes (179 Kb)
opened URL
downloaded 179 Kb

package 'yags' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Documents and Settings\j\Local
Settings\Temp\RtmpXGE7rd\downloaded_packages
updating HTML package descriptions
---

then i tried:

---
> help("yags")
No documentation for 'yags' in specified packages and libraries:
you could try 'help.search("yags")'
---

help.search doesn't help. when i type library() the result says:

---
Packages in library 'C:\Documents and Settings\j\My
Documents/R/win-library/2.6':

yags  Yet Another GEE Solver

Packages in library 'C:/PROGRA~1/R/R-26~1.0/library':

base  The R Base Package
boot  Bootstrap R (S-Plus) Functions (Canty)
class Functions for Classification
cluster   Cluster Analysis Extended Rousseeuw et al.
...
---

i've checked the Admin and Maint manual, but i'm stumped as to how to get
yags to actually work. i copied and pasted the example from the html file
in the yags folder and after every line that called yags, there was an
error message that said:
Error: could not find function "yags".

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] installing and using a package

2008-01-10 Thread jpolo
i'm trying to learn R. i have no programing experience. i tried to add on
a package and just picked "yags". i can't get it to work or get any help.

---
> install.packages("yags")
Warning in install.packages("yags") :
  argument 'lib' is missing: using 'C:\Documents and Settings\j\My
Documents/R/win-library/2.6'
trying URL
'http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.6/yags_4.0-2.zip'
Content type 'application/zip' length 183779 bytes (179 Kb)
opened URL
downloaded 179 Kb

package 'yags' successfully unpacked and MD5 sums checked

The downloaded packages are in
C:\Documents and Settings\j\Local
Settings\Temp\RtmpXGE7rd\downloaded_packages
updating HTML package descriptions
---

then i tried:

---
> help("yags")
No documentation for 'yags' in specified packages and libraries:
you could try 'help.search("yags")'
---

help.search doesn't help. when i type library() the result says:

---
Packages in library 'C:\Documents and Settings\j\My
Documents/R/win-library/2.6':

yags  Yet Another GEE Solver

Packages in library 'C:/PROGRA~1/R/R-26~1.0/library':

base  The R Base Package
boot  Bootstrap R (S-Plus) Functions (Canty)
class Functions for Classification
cluster   Cluster Analysis Extended Rousseeuw et al.
...
---

i've checked the Admin and Maint manual, but i'm stumped as to how to get
yags to actually work. i copied and pasted the example from the html file
in the yags folder and after every line that called yags, there was an
error message that said:
Error: could not find function "yags".

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] error message translation

2008-01-10 Thread jpolo
sorry if my first msg was posted twice. this email system at school sucks.

i've looked in the Admin and Main manual and the Intro manual for
something that tells me what error messages mean, but haven't found
anything. where can i find the meanings of the error messages?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] installing and using a package

2008-01-10 Thread jpolo
> R distinguishes between "installing" and "loading" a package. It looks
> like your installation of yags went fine. Now type
> library(yags)
> to load the package.
> now help(yags) should bring up something, as should example(yags) .
that helped. thank you

john

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] installing and using a package

2008-01-10 Thread jpolo
>> -Original Message-


> You need to read the "An Introduction to R" manual which was probably
> installed when you installed R on your un-named OS (Windows, I take it).
yes, i did find what i needed there. thanks you.

john

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] installing and using a package

2008-01-10 Thread jpolo
> I'm not sure what you have done but using a package requires two steps:
> 1) installing or downloading the package,
> 2) loading an installed package.
>
> Since you are using windows you can click on Packages, Install packages,
> and
> after choosing a CRAN mirror, selecting the package you want.  R will do
> the
> rest and tell you that it has installed the package (which it apparently
> has
> in your case).
>
> Now click on Packages again and choose Load package.
that helped. thank you

john

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] error message translation

2008-01-10 Thread jpolo

> Do you mean expansions on the terse messages, or translations from
> another language?  There aren't really any expansions available: the
> messages are supposed to be clear in themselves.  If you really want to
> know why you got one you might be able to look it up in the source code,
> but generally the best thing is to ask a few times on this list, and
> then you'll pick up the style, and will generally just recognize them.
>
> Duncan Murdoch
yes, i meant an expansion. you've helped me though. thank you.

john

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.