[Highfrequency-commits] r31 - pkg/highfrequency/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Aug 13 01:05:26 CEST 2012


Author: jonathan
Date: 2012-08-13 01:05:25 +0200 (Mon, 13 Aug 2012)
New Revision: 31

Modified:
   pkg/highfrequency/R/realized.R
Log:
comments kris update: heavyModel error handling

Modified: pkg/highfrequency/R/realized.R
===================================================================
--- pkg/highfrequency/R/realized.R	2012-08-09 00:13:57 UTC (rev 30)
+++ pkg/highfrequency/R/realized.R	2012-08-12 23:05:25 UTC (rev 31)
@@ -3994,12 +3994,21 @@
   ui   = diag(rep(1,KKK));          #All parameters should be larger than zero, add extra constraints with rbind...  
   ci   = matrix(rep(0,dim(ui)[2]),ncol=1);  
   
-  x = optim( par = startingvalues, fn = heavy_likelihood,
-             data=data, p=p, q=q,backcast=backcast,UB=UB,LB=LB, compconst = compconst ); # ADJUST maxit ?!!
+  x = try(optim( par = startingvalues, fn = heavy_likelihood,
+                 data=data, p=p, q=q,backcast=backcast,UB=UB,LB=LB, compconst = compconst ) ); # ADJUST maxit ?!!
   #  x = constrOptim( theta = startingvalues, f = heavy_likelihood, 
   #                    grad=NULL,ui=ui, ci = ci, 
   #                    data=data, p=p, q=q,backcast=backcast,UB=UB,LB=LB, compconst = compconst ); 
   
+  
+  if( class(x)=="try-error"){
+    print("Error in likelihood optimization")
+    print(x)
+  }else{
+    if(x$convergence != 0){
+      print("Possible problem in likelihood optimization. Check convergence")   }
+  }
+  
   # Get the output: 
   estparams = x$par; 
   loglikelihood = x$value; 
@@ -4007,10 +4016,10 @@
   # Get the list with: total-log-lik, daily-log-lik, condvars
   xx = heavy_likelihood(parameters = estparams, data=data, p=p, q=q, backcast=backcast, LB=LB, UB=UB, foroptim=FALSE, compconst = compconst);
   xx$estparams =  estparams;
+  xx$convergence = x$convergence
   
   return(xx)
-}  
-
+}
 transformparams = function( p, q, paramsvector ){
   K = dim(p)[1]; 
   pmax = max(p); qmax = max(q); # Max number of lags for innovations and cond vars



More information about the Highfrequency-commits mailing list