From: Daomeng Gao <daomeng_at_googlemail.com>

Date: Tue, 29 Apr 2008 14:39:30 +0200

}

Cder<-0.5*(Cder+t(Cder))

Cder

}

R-help_at_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. Received on Tue 29 Apr 2008 - 13:01:32 GMT

Date: Tue, 29 Apr 2008 14:39:30 +0200

Hello R-help,

I need to compute matrices of first derivatives of a covariance matrix C with entries given by c_ij=theta*exp(-0.5* sum(eta*(x[i,]-x[j,])^2)), wrt to elements of eta, a m-dimensional vector of parameters, given a n*m data matrix x. So far, I have been computing matrices for each parameter (given by par[index]) analytically, using the following

kmatder<- function(x, par, index) {

* ## x: n*m matrix
*

## par: vector of parameters, m=length(par)=ncol(x)

## compute matrix of partial derivatives wrt parameter par[index]: Cder

= d C/d par[index]

theta<-1

eta<-par

n<-nrow(x)

Cder<-matrix(0,n,n)

for (i in 1:n) {

for (j in i:n) { Cder[i,j]<-(-0.5*((x[i,index]-x[j,index])^2))*theta*exp(-0.5* sum(eta*(x[i,]-x[j,])^2)) }

}

Cder<-0.5*(Cder+t(Cder))

Cder

}

I was wondering whether it might be possible to speed up things using numDeriv (jacobian). If so, what would be the right way to implement a suitable method ?

Cheers,

Gao Daomeng

[[alternative HTML version deleted]]

R-help_at_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. Received on Tue 29 Apr 2008 - 13:01:32 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Wed 30 Apr 2008 - 15:30:32 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*