*Hallo, lists:*
*
*
*  I came to an error for xts package : * "order.by requires an appropriate
time-based object".
* It seems there is no explicit solution to this problem, so would you
please do me a favor and give me some further advice ?*
*My current version for R is 2.14.0, and relevant codes are as follows :*

library(tseries)

library(quantmod)

GSPC <- as.xts(get.hist.quote("^GSPC",start="2000-01-02",
          quote=c("Open", "High", "Low", "Close","Volume","AdjClose")))

T.ind <- function(quotes,tgt.margin=0.025,n.days=10) {
  v <- apply(HLC(quotes),1,mean)

  r <- matrix(NA,ncol=n.days,nrow=NROW(quotes))
  for(x in 1:n.days) r[,x] <- Next(Delt(v,k=x),x)

  x <- apply(r,1,function(x) sum(x[x > tgt.margin | x < -tgt.margin]))
  if (is.xts(quotes)) xts(x,time(quotes)) else x
}

ex.model <- specifyModel(T.ind(GSPC) ~ Delt(Cl(GSPC),k=1:3))

*
*
*Best,*
*Haiping Lan /Guosen Securities Co.*

*
*

-- 
  Haiping LAN

	[[alternative HTML version deleted]]

