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
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.
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
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
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
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
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
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]
8 matches
Mail list logo