Programming

Posted 07:00 PST Wed Mar 19, 2008 in

I wrote my first “R”: script yesterday. It’s a simple script that computes the joint probability from the observations — the empirical distribution. I need this to use in testing the fits of the copulas I’m fitting.

The code looks like:

dufus<-function(peak,vol) {n<-length(peak) jp<-matrix(rep(0,n)) for (i in 1:n) { j2<-vol-vol[i] numv<-sum(j2<=0) jp[i]<-(numv-0.44)/(n+0.12) } jp}

Right now I’m not using the variable peak for anything, but I put it in the argument list so I could use it later as I modify the script. I see I could drop j2 and put the computation inside the sum function. That would be slightly more efficient, but I wasn’t thinking efficiency when I wrote the script. I just need to solve the problem.

That leads to another problem I’m working on. The parameter for the Frank copula requires solution of a Debye function. I’ve been doing some reading on how to either approximate the function or integrate it. I found an ACM algorithm that will do the trick. But, I’ll have to recast the code in R, I think. I’ll figure that one out later.

Now off to work…

Name
Email (never displayed)
website (include http://)
Message
  Textile Help