[R-SIG-Finance] specifyModel/buildModel/tradeModel

Worik worik.stanton at gmail.com
Sun Mar 28 07:15:29 CEST 2010


I am trying to work out what these functions do.

How is the model in specifyModel used?

What are the restrictions on the sorts of models that can be used?

Here are some of my experiments.  I do not know why only Next(OpCl(AIA.NZ)) ~ 
Lag(OpHi(AIA.NZ)) works for all stages.

> f1
Op(AIA.NZ) ~ EMA(Op(AIA.NZ))
> f2
Op(AIA.NZ) ~ Lag(AIA.NZ)
> f3
Op(AIA.NZ) ~ EMA(Op(AIA.NZ))
> f4
Next(OpCl(AIA.NZ)) ~ Lag(OpHi(AIA.NZ))
> m1 <- specifyModel(f1)
> m2 <- specifyModel(f2)
Error in dimnames(x) <- dn : 
  length of 'dimnames' [1] not equal to array extent
> m3 <- specifyModel(f3)
> m4 <- specifyModel(f4)
> b1 <- buildModel(m1, method='rpart', 
training.per=c('2007-01-01','2007-04-01'))
> b3 <- buildModel(m3, method='rpart', 
training.per=c('2007-01-01','2007-04-01'))
> b4 <- buildModel(m4, method='rpart', 
training.per=c('2007-01-01','2007-04-01'))
> tradeModel(b1)
Error in `[.zoo`(neg.days, , 1) : subscript out of bounds
In addition: Warning message:
In modelReturn(quantmodResults, trade.dates = trade.dates, leverage = 
leverage,  :
  Model results are all one direction.
> tradeModel(b3)
Error in `[.zoo`(neg.days, , 1) : subscript out of bounds
In addition: Warning message:
In modelReturn(quantmodResults, trade.dates = trade.dates, leverage = 
leverage,  :
  Model results are all one direction.
> tradeModel(b4)

  Model:  rpart1269752986.98017 

  C.A.G.R.:  -9.62% 	H.P.R.:  -35.37% 

  Returns by period summary:

             weekly monthly quarterly  yearly
    Max.      7.99%  12.57%    25.20%  58.18%
    3rd Qu.   1.80%   3.76%    11.03%   9.80%
    Mean     -0.23%  -0.94%    -2.39%  -2.64%
    Median   -0.20%  -0.59%    -3.56%  -8.70%
    2rd Qu.  -2.12%  -4.93%   -13.31% -21.14%
    Min.    -12.76% -26.11%   -33.25% -51.34%

  Period to date returns:

             weekly monthly quarterly yearly
             -0.52%   0.89%    -6.33% -6.33%
> 

I have version 0.3-8 of quantmod
R version 2.9.2

cheers
Worik



More information about the R-SIG-Finance mailing list