Re: [R] help about solving two equations

2010-03-13 Thread Berend Hasselman
Ravi Varadhan wrote: > > require(BB) > > fn <- function(x, s){ > f <- rep(NA, length(x)) > f[1] <- digamma(x[1]) - digamma(x[1]+x[2]) - s[1] > f[2] <- digamma(x[2]) - digamma(x[1]+x[2]) - s[2] > f > } > > nr <- 10 > smat <- matrix(runif(2*nr, -3, -1), nr, 2) > soln <- matrix(NA, nr, 2

Re: [R] help about solving two equations

2010-03-12 Thread Ravi Varadhan
Ravi Varadhan" To: "Shaoqiong Zhao" Cc: r-help@r-project.org Sent: Thursday, March 11, 2010 8:02:43 PM GMT -06:00 US/Canada Central Subject: Re: [R] help about solving two equations You have to install it from CRAN before you can load it into your session.

Re: [R] help about solving two equations

2010-03-11 Thread Shaoqiong Zhao
anks a lot. Annie - Original Message - From: "Ravi Varadhan" To: "Shaoqiong Zhao" Cc: r-help@r-project.org Sent: Wednesday, March 10, 2010 9:03:25 PM GMT -06:00 US/Canada Central Subject: Re: [R] help about solving two equations Here is how you can solve: fn <- funct

Re: [R] help about solving two equations

2010-03-11 Thread Ravi Varadhan
email: rvarad...@jhmi.edu - Original Message - From: Shaoqiong Zhao Date: Thursday, March 11, 2010 9:00 pm Subject: Re: [R] help about solving two equations To: Ravi Varadhan Cc: r-help@r-project.org > Hello Professor Ravi, > > I tried to load BB into R, but I got the

Re: [R] help about solving two equations

2010-03-11 Thread Berend Hasselman
Shaoqiong Zhao wrote: > > > I am not sure if this is correct and also this can only solve one row. How > to get the whole 1000 rows of p and q? > You can try something like this: library(nleqslv) library(BB) fn <- function(x, s){ f <- rep(NA, length(x)) f[1] <- digamma(x[1]) - d

Re: [R] help about solving two equations

2010-03-10 Thread Berend Hasselman
Shaoqiong Zhao wrote: > > I have two matrix s1 and s2, each of them is 1000*1. > and I have two equations: > digamma(p)-digamma(p+q)=s1, > digamma(q)-digamma(p+q)=s2, > and I want to sovle these two equations to get the value of x and y, which > are also two 1000*1 matrices. > Besides BB there

Re: [R] help about solving two equations

2010-03-10 Thread Ravi Varadhan
Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Shaoqiong Zhao Date: Wednesday, March 10, 2010 8:19 pm Subject: [R] help about solving two equations To: r-help@r-project.org > I have

[R] help about solving two equations

2010-03-10 Thread Shaoqiong Zhao
I have two matrix s1 and s2, each of them is 1000*1. and I have two equations: digamma(p)-digamma(p+q)=s1, digamma(q)-digamma(p+q)=s2, and I want to sovle these two equations to get the value of x and y, which are also two 1000*1 matrices. I write a program like this: f <- function(x) { p<- x[1]