Re: T Copula Calibration
- To: mathgroup at smc.vnet.net
- Subject: [mg78547] Re: [mg78530] T Copula Calibration
- From: Carl Woll <carlw at wolfram.com>
- Date: Wed, 4 Jul 2007 05:29:38 -0400 (EDT)
- References: <200707030944.FAA18997@smc.vnet.net>
dwstrickler at tx.rr.com wrote: > All, > > In the interest of full disclosure and genuine humility, I don't code > in Mathematica so much as I wrestle it into submission from time to > time. Accordingly, I've come up against an optimization problem in > which Mathematica flatly refuses to see things my way. In a nutshell, > I have an n x 3 table of interdependent log-delta price data (to the > extent it matters, I have a corresponding table of alpha-Stable > standardized log-delta price data), and I'm trying to construct a > simulation algorithm that will effectuate a Student T copula > relationship between the three variables. (FWIW, I've managed to > create Clayton and Gumbel copula RNGs for similar data; they work > fine). > > The problem is the Student T copula density function, and in > particular, the Student T DOF parameter, v. I've tried NMinimize, > FindMinimum, and FindRoot, and I simply cannot get Mathematica to return a > numerical value for v. In fact, the problem is broader than that - I > can't get Mathematica to optimize ANY function that contains a Sum or > Product > term - but I digress. > > In terms of the density function, here's an example of what I've > tried: > > tCopulaPDF[y__,v_,R_]:=Module[{dims,ret},dims=Length[Transpose[y]];ret=((Gamma > [(v+dims)/2]*(Gamma[v/2])^dims-1)/(Gamma[(v+1)/ > 2]^dims)*(Det[R])^1/2)*NProduct[(1+ > (y[[i]]^2/v))^v+1/2,{i,1,dims}]*(1+y.R^-1*y/v)^-v+dims/2;Return[ret]]; ^^^^^^ It's unnecessary to use Return here. Module automatically returns the last expression. Without creating data to test your code, I suspect that the problem is that NMinimize attempts to evaluate tCopulaPDF with a symbolic v. If so, the simple workaround is to use tCopulaPDF[y_, v_?NumberQ, R_] := ... If the above doesn't solve your problem, make sure that tCopulaPDF[data, 1, corrmat] evaluates to a number. Another possible issue is the use of R^-1. Did you mean to use Inverse[R] here instead? Carl Woll Wolfram Research > > where y is the n x 3 table, v is the DOF parameter, and R is the > correlation matrix for y. Gamma[] is Mathematica's built-in Euler Gamma > function. > > Then I try to optimize with something like: > > NMinimize[{tCopulaPDF[data,v,corrmat],v>0},v] > > No luck. Mathematica gives me the standard NAN warning, and then > returns the > function unevaluated. > > Thinking the source of the problem might be the NProduct term, I also > tried expressing the density function a different way: > > tCopulaPDF[y__,v_,R_]:=Module[{dims,ret,cols,a,b,c},dims=Length[Transpose[y]];cols=y/. > {a_,b_,c_}:>Apply[Times,(1+a^2/v)^v+1/2]+Apply[Times,(b^2/v)^v > +1/2]+Apply[Times,(c^2/v)^v > +1/2];ret=((Gamma[(v+dims)/2]*(Gamma[v/2])^dims-1)/(Gamma[(v+1)/ > 2]^dims)*(Det[R])^1/2) > *cols*(1+y.R^-1*y/v)^-v+dims/2;Return[ret]]; > > Same result. Any suggestions? I apologize in advance if the solution > is blindingly obvious to everyone but me. >
- References:
- T Copula Calibration
- From: dwstrickler@tx.rr.com
- T Copula Calibration