全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 MATLAB等数学软件专版
2011-7-18 14:55:49
Problem: Object "meanDur5min.msft" not found
Use traceback() to see the call stack
> meanDur5min.ave.msft@title = "5-min Mean Durations: MSFT\n(averaging across 11 trading days)"
Problem: Object "meanDur5min.ave.msft" not found
Use traceback() to see the call stack
>
> # plots of ACF and calendar pattern in durations
> par(mfrow = c(1,2))
> acf.plot(acf(meanDur5min.msft, lag.max = 234, plot = F),
+      main = "ACF of 5-min Mean Durations:\nMSFT (lags up to 3 days)")
Problem: Object "meanDur5min.msft" not found
Use traceback() to see the call stack
> plot(meanDur5min.ave.msft, reference.grid = F,
+      x.axis.args = list(format.label = c("%H:%02M", "%Z"),
+                        time.of.day.style = "24:00"))
Problem: Object "meanDur5min.ave.msft" not found
Use traceback() to see the call stack
>
> ## USD/EUR
> ## mean durations in 5-min intervals
> meanDur5min.eurusd = aggregateSeriesHF(duration.eurusd, interv.type = "weekly",
+                       bound.hours = c("22:00", "22:00"), FUN = mean,
+                      by = "minutes", k.by = 5, adj = 1, drop.empty = F, together = T)
Problem: Object "duration.eurusd" not found
Use traceback() to see the call stack
> meanDur5min.eurusd[1:5,]
Problem: Object "meanDur5min.eurusd" not found
Use traceback() to see the call stack
>
> # averaging 5-min mean durations across trading days
> meanDur5min.ave.eurusd = SmoothAcrossIntervs(ts = meanDur5min.eurusd, n.subinterv = 288,
+                                    n.interv = 5, FUN = mean)
Problem: Object "meanDur5min.eurusd" not found
Use traceback() to see the call stack
> meanDur5min.ave.eurusd@title = "5-min Mean Durations: USD/EUR\n(averaging across 11 trading days)"
Problem: Object "meanDur5min.ave.eurusd" not found
Use traceback() to see the call stack
>
> # plots of ACF and calendar pattern in durations
>         #removing the NAs in meanDur5min before plotting ACF
>         na.idx = is.na(seriesData(meanDur5min.eurusd))
Problem: Object "meanDur5min.eurusd" not found
Use traceback() to see the call stack
> par(mfrow = c(1,2))
> acf.plot(acf(meanDur5min.eurusd[!na.idx,], lag.max = 864, plot = F),
+      main = "ACF of 5-min Mean Durations:\nUSD/EUR (lags up to 3 days)")
Problem: Object "meanDur5min.eurusd" not found
Use traceback() to see the call stack
> plot(meanDur5min.ave.eurusd, reference.grid = F,
+      x.axis.args = list(format.label = c("%H:%02M", "%Z"),
+                        time.of.day.style = "24:00"))
Problem: Object "meanDur5min.ave.eurusd" not found
Use traceback() to see the call stack
>
> ### 3.3.3 Calendar patterns in the frequency of trades or quotes ###
> ## MSFT
> # construct an aux series to count trades
> aux.msft = timeSeries(data.frame(Ticks = rep(1, nrow(msftt.ts))),
+             pos = msftt.ts@positions)
>
> # the number of trades in 5-min intervals
> trades5min.msft = aggregateSeriesHF(aux.msft, interv.type = "daily",
+                       bound.hours = c("9:30", "16:00"), FUN = sum,
+                      by = "minutes", k.by = 5, adj = 1, drop.empty = F, together = T)
Problem in sub(ts@data, idx,  ): argument "x" is missing with no default
Use traceback() to see the call stack
> trades5min.msft[1:5,]
Problem: Object "trades5min.msft" not found
Use traceback() to see the call stack
>
> # averaging the number of trades in 5-min intervals across trading days
> trades5min.ave.msft = SmoothAcrossIntervs(ts = trades5min.msft, n.subinterv = 78,
+                                    n.interv = 11, FUN = mean)
Problem: Object "trades5min.msft" not found
Use traceback() to see the call stack
> trades5min.ave.msft@title = "Number of Trades in 5-min Intervs: MSFT\n(averaging across 11 trading days)"
Problem: Object "trades5min.ave.msft" not found
Use traceback() to see the call stack
>
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-18 14:56:13
# plots of ACF and calendar pattern in trades number
> par(mfrow = c(1,2))
> acf.plot(acf(trades5min.msft, lag.max = 234, plot = F),
+      main = "ACF of Number of Trades in 5-min Intervs:\nMSFT (lags up to 3 days)")
Problem: Object "trades5min.msft" not found
Use traceback() to see the call stack
> plot(trades5min.ave.msft, reference.grid = F,
+      x.axis.args = list(format.label = c("%H:%02M", "%Z"),
+                        time.of.day.style = "24:00"))
Problem: Object "trades5min.ave.msft" not found
Use traceback() to see the call stack
>
> ## USD/EUR
> # construct an aux series to count quotes
> aux.eurusd = timeSeries(data.frame(Ticks = rep(1, nrow(eurusd.ts))),
+               pos = eurusd.ts@positions)
>
> # the number of quotes in 5-min intervals
> quotes5min.eurusd = aggregateSeriesHF(aux.eurusd, interv.type = "weekly",
+                       bound.hours = c("22:00", "22:00"), FUN = sum,
+                      by = "minutes", k.by = 5, adj = 1, drop.empty = F, together = T)
Problem in sub(ts@data, idx,  ): argument "x" is missing with no default
Use traceback() to see the call stack
> quotes5min.eurusd[1:5,]
Problem: Object "quotes5min.eurusd" not found
Use traceback() to see the call stack
>
> # averaging the number of quotes in 5-min intervals across trading days
> quotes5min.ave.eurusd = SmoothAcrossIntervs(ts = quotes5min.eurusd, n.subinterv = 288,
+                                    n.interv = 5, FUN = mean)
Problem: Object "quotes5min.eurusd" not found
Use traceback() to see the call stack
> quotes5min.ave.eurusd@title = "Number of Quotes in 5-min Intervs: USD/EUR\n(averaging across 11 trading days)"
Problem: Object "quotes5min.ave.eurusd" not found
Use traceback() to see the call stack
>
> # plots of ACF and calendar pattern in quotes number
> par(mfrow = c(1,2))
> acf.plot(acf(quotes5min.eurusd, lag.max = 864, plot = F),
+      main = "ACF of Number of Quotes in 5-min Intervs:\nUSD/EUR (lags up to 3 days)")
Problem: Object "quotes5min.eurusd" not found
Use traceback() to see the call stack
> plot(quotes5min.ave.eurusd, reference.grid = F,
+      x.axis.args = list(format.label = c("%H:%02M", "%Z"),
+                        time.of.day.style = "24:00"))
Problem: Object "quotes5min.ave.eurusd" not found
Use traceback() to see the call stack
>
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-18 14:59:03
traceback()
5: eval(action, sys.parent())
4: doErrorAction("Problem: Object \"quotes5min.ave.eurusd\" not found", 1000)
3: plot(quotes5min.ave.eurusd, reference.grid = F, x.axis.args = list(format.label = c("%H:%02M", "%Z"),
2: eval(expression(plot(quotes5min.ave.eurusd, reference.grid = F, x.axis.args = list(format.label = c("%H:%02M
",
1:
Message: Problem: Object "quotes5min.ave.eurusd" not found
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-18 19:03:41
> gibbs1 <- function(nits,y,mu0=0,tau0=1){
+ alphas <- 0.1
+ betas <- 0.01
+ mus <- 0.0
+ taus <- 1.0
+ x <- array(0,c(nits+1,2))
+ x[1,1] <- mu0
+ x[1,2] <- tau0
+ n <- length(y)
+ ybar <- mean(y)
+ for(t in 2:(nits+1)){
+ x[t,1]_RNORM(1,(n*ybar*x[t-1,2]+mus*taus)/
错误: 意外的输入 于
"for(t in 2:(nits+1)){
x[t,1]_"
> (n*x[t-1,2]+taus),
错误: 意外的','在"(n*x[t-1,2]+taus),"里
> sqrt(1/(n*x[t-1,2]+taus)))
错误: 意外的')'在"sqrt(1/(n*x[t-1,2]+taus)))"里
> sn_sum((y-x[t,1])^2)
错误: 没有"sn_sum"这个函数
> x[t,2]_RGAMMA(1,alphas+n/2)
错误: 意外的输入在"x[t,2]_"里
> /(betas+sn/2)}
错误: 意外的'/'在"/"里
> x
错误: 找不到对象'x'
> }
epoh老师,以上代码错在什么地方?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-18 20:54:48
nits=100
set.seed(123)
y=rnorm(100)
gibbs1 <- function(nits,y,mu0=0,tau0=1){
alphas <- 0.1
betas <- 0.01
mus <- 0.0
taus <- 1.0
x <- array(0,c(nits+1,2))
x[1,1] <- mu0
x[1,2] <- tau0
n <- length(y)
ybar <- mean(y)
for(t in 2:(nits+1)){
x[t,1]=rnorm(1,(n*ybar*x[t-1,2]+mus*taus)/(n*x[t-1,2]+taus),sqrt(1/(n*x[t-1,2]+taus)))
sn=sum((y-x[t,1])^2)
x[t,2]=rgamma(1,alphas+n/2)/(betas+sn/2)}
x
}
gibbs1(nits,y)
               [,1]              [,2]
  [1,]  0.0000000000 1.0000000
  [2,]  0.0188227055 1.2388372
  [3,]  0.0676069255 1.1429600
  .......
  .......
[99,]  0.1772417126 1.2318935
[100,]  0.1989838980 0.9707243
[101,] -0.0488330617 1.2237534

#########
HFLibrary三四年前我曾用过,
不过因为是建构于S-PLUS 6.2,
现在在s-plus 8.0执行上,的确有些问题,
虽然FinMetrics 3.0.已经带进了HFLibrary
不过还是存在些问题.
我再抽空看看.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-18 22:18:18
35# epoh
我用的是splus8.0, Finmetrics3.02,
我不明白的是这个HFlibrary.ssc是做什么用的?在
splus中如何调用?我把它copy and then paste into 到splus的根目录中的library
文件夹中,但是在splus中无法load library,所以不知道如何使用HFlibrary.
还有附件中的几个ssc程序也无法在splus8中运行。
附件列表

5555.rar

大小:23.68 KB

 马上下载

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-18 22:56:53
哈哈,epoh老师,我和zhangtao兄有同样疑问

.ssc是s-plus软件中自己编写的程序后缀名吗?

S-PLUS script for examples in paper: HFAnalysis.ssc
S-PLUS HF library: HFLibrary.SSC. Note: some of the functions in the HF library require the S+FinMetrics?
HFLibrary.SSC怎么判别是一个包?
我看了C:\Program Files\Insightful\splus80\library里面的,都没有SSC结尾的。
能不能这样说,他是一个外部包,而不是s-plus自带的?

还有一般安装包是用
install.packages("  ")
我看到一个包pkgutils是这样安装的install.pkgutils(),有什么区别规则吗?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-19 07:10:57
模块module和包library有何区别?是moduel包含了library?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-19 10:15:13
> # Created on 02/20/2003
# By Bingcheng Yan
# Last updated on 11/06/2003
## Moved utility functions to the HF Library
## The library has to be attached to run this script file
## Functions used in the script file:
## TAQLoad()
## OlsenLoad()
## reorderTS()
## plotByDays()
## ExchangeHoursOnly()
## FxBizWeekOnly()
## align.withinDay()
## align.withinWeek()
## diff.withinDay()
## diff.withinWeek()
## is.tsBW()
## tsBW()
## DurationInInterv()
## PriceChgInInterv()
## getSpread()
## SmoothAcrossIntervs()
## tableSmoother()
## rbindtimeSeries()
## aggregateSeriesHF()
## tradeDirec()
## Genr.RealVol()
## Attach the FxLibrary
attach("D:\\Consulting\\FxLibrary", pos = 2, name = "FxLibrary")
> ## Load the FinMetrics module
module("finmetrics", first = F)
> #################### Section 2 Data Proceesing ####################################
### loading MSFT Trade data ####
msftt.ts = TAQLoad(file = "D:\\CompFinProg\\HFAnalysis\\trade_msft.txt", type = "trade")
> msftt.ts[1:5,  ]
        Positions Cond Ex Symbol Corr G127    Price Size Seq
5/1/1997 8:01:02 T    T  MSFT   0    0    121.1250 1500 0  
5/1/1997 8:02:24 T    T  MSFT   0    0    121.5625  500 0  
5/1/1997 8:03:20 T    T  MSFT   0    0    121.5625 1000 0  
5/1/1997 8:03:22 T    T  MSFT   0    0    121.5625 1200 0  
        Positions Cond Ex Symbol Corr G127    Price Size Seq
5/1/1997 8:38:15 T    T  MSFT   0    0    121.6250 1000 0  
> slotNames(msftt.ts)
[1] "data"              "positions"         "start.position"    "end.position"      "future.positions"
[6] "units"             "title"             "documentation"     "attributes"        "fiscal.year.start"
[11] "type"            
> msftt.ts@data[1:5,  ]
  Cond Ex Symbol Corr G127    Price Size Seq
1    T  T   MSFT    0    0 121.1250 1500   0
2    T  T   MSFT    0    0 121.5625  500   0
3    T  T   MSFT    0    0 121.5625 1000   0
4    T  T   MSFT    0    0 121.5625 1200   0
  Cond Ex Symbol Corr G127    Price Size Seq
5    T  T   MSFT    0    0 121.6250 1000   0
> msftt.ts@positions[1:5]
[1] 5/1/1997 8:01:02 5/1/1997 8:02:24 5/1/1997 8:03:20 5/1/1997 8:03:22 5/1/1997 8:38:15
> ### loading MSFT Quote data ###
msftq.ts = TAQLoad("D:\\CompFinProg\\HFAnalysis\\quote_msft.txt", type = "quote")
> msftq.ts[1:5,  ]
        Positions Ex MMID Symbol     Bid BidSize Mode     Ask AskSize Seq
5/1/1997 8:17:24 T       MSFT   121.500 11      12   121.625 11      0  
5/1/1997 9:00:44 T       MSFT   121.750 10      12   121.625 11      0  
5/1/1997 9:07:27 T       MSFT   121.750 10      12   121.625 10      0  
5/1/1997 9:16:30 T       MSFT   121.875 10      12   121.625 10      0  
        Positions Ex MMID Symbol     Bid BidSize Mode     Ask AskSize Seq
5/1/1997 9:20:29 T       MSFT   121.875 10      12   121.625  3      0  
> ### loading GE Trade data ####
get.ts = TAQLoad("D:\\CompFinProg\\HFAnalysis\\trade_ge.txt", type = "trade")
> get.ts[1:5,  ]
        Positions Cond Ex Symbol Corr G127   Price  Size     Seq
5/1/1997 9:30:17      N  GE     0    0    110.625 78700 3689550
5/1/1997 9:30:20      M  GE     0    0    110.625   100       0
5/1/1997 9:30:20      M  GE     0    0    110.625   100       0
5/1/1997 9:30:20      M  GE     0    0    110.625   300       0
        Positions Cond Ex Symbol Corr G127   Price  Size     Seq
5/1/1997 9:30:20      M  GE     0    0    110.625   100       0
> ### loading GE Quote data ###
geq.ts = TAQLoad("D:\\CompFinProg\\HFAnalysis\\quote_ge.txt", type = "quote")
> geq.ts[1:5,  ]
        Positions Ex MMID Symbol     Bid BidSize Mode    Ask AskSize     Seq
5/1/1997 9:00:44 T  TRIM GE       0.000 0       12     0.00  0            0
5/1/1997 9:00:44 T  MADF GE       0.000 0       12     0.00  0            0
5/1/1997 9:30:20 C       GE     106.125 5       12     0.00  0            0
5/1/1997 9:30:27 N       GE     110.625 5       10   110.75 10      3689560
        Positions Ex MMID Symbol     Bid BidSize Mode    Ask AskSize     Seq
5/1/1997 9:30:30 M       GE     109.125 5       12   111.00  1            0
> ### loading USD/EUR data ###
eurusd.ts = OlsenLoad("D:\\CompFinProg\\HFAnalysis\\eur_usd.txt")
> eurusd.ts[1:5,  ]
         Positions    Bid    Ask Institution
3/11/2001 1:07:46 0.9337 0.9342 AREX      
3/11/2001 1:07:52 0.9336 0.9341 AREX      
3/11/2001 1:07:57 0.9334 0.9339 AREX      
3/11/2001 1:08:04 0.9337 0.9342 AREX      
         Positions    Bid    Ask Institution
3/11/2001 5:42:35 0.9330 0.9340 CMBK      
> eurusd.ts[1:5, "Bid"]
         Positions    Bid
3/11/2001 1:07:46 0.9337
3/11/2001 1:07:52 0.9336
3/11/2001 1:07:57 0.9334
3/11/2001 1:08:04 0.9337
         Positions    Bid
3/11/2001 5:42:35 0.9330
> #### Data examination and cleaning ###
# Re-order data series
msftt.ts = reorderTS(msftt.ts)
Problem in sub(x.data, pos.order,  ): argument "x" is missing with no default
Use traceback() to see the call stack
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-19 10:18:35
Problem in sub(x.data, pos.order,  ): argument "x" is missing with no default
以上这个错误不解决,程序无法继续进行,这个x.data是什么?有没有?如何创建?
## Moved utility functions to the HF Library
## The library has to be attached to run this script file
这个HFLibarary.SSC如何attached?

## Attach the FxLibrary
attach("D:\\Consulting\\FxLibrary", pos = 2, name = "FxLibrary")
这个FxLibary是什么,有什么用?原程序包中没有这个FxLibary,那儿有?
以上问题如果解决,估计程序就可以用了。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-19 10:31:54
当下载一个.ssc file,要使用时,
最好先打开看看,需要配合的函数数据
就以为例checkSV.ssc
需要用到ssfnong.ssc,sv_mcl_est.ssc,module("finmetrics")
以及数据svpdx.dat
所以我把底下这几行加在checkSV.ssc的前面,
svpdx.dat=read.table("c:/checkSV/svpdx.dat")
source("c:/checkSV/ssfnong.ssc")
source("c:/checkSV/sv_mcl_est.ssc")
module("finmetrics")

执行的方式有两种:
1.source("c:/checkSV/checkSV.ssc")

2.File \Open\checkSV.ssc,
     then from Script menu, choose run.

svpdx.dat,checkSV.ssc,ssfnong.ssc,sv_mcl_est.ssc
  
checkSV.rar
大小:(15.83 KB)

 马上下载



###############
底下回答ywh19860616兄
.ssc是s-plus软件中自己编写的程序后缀名.(S-PLUS script)

HFLibrary.SSC 只是为了Analysis of High Frequency Financial Data

作者所写的函数集合.

HFAnalysis.ssc 是给数据,给参数的运行程序

如果你要安装s-plus package
程序如下:

install.pkgutils()


library(pkgutils)


install.packages("resample")


  http://home.comcast.net/~timhesterberg/bootstrap/

这里有很多s-plus package可供下载

  http://csan.insightful.com/



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-19 10:34:47
在HFLibrary.SSC中有以下几行:
reorderTS = function(x)
{
                x.pos = positions(x)
                x.data = seriesData(x)
       
                pos.order = order(x.pos)
                x.pos = x.pos[pos.order]
                x.data = sub(x.data, pos.order,)
所以我觉得这个程序运行的关键还是如何把HFLibrary.SSC载入?
我以上想法,希望epoh老师参考。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-19 10:38:42
运行HFLibrary.SSC提示以下错误:
        # finishing "bracketing"
        nona.seqNum = c(0, nona.seqNum, x.row + 1)
        # NA duration is only defined for those blocks
        #(bracketed by two nonNAs) that have two or more
        # consecutive NAs, find them
        key.seqNum = nona.seqNum[c(F, diff(nona.seqNum) > 2)]
        key.seqNum.idx = match(key.seqNum, nona.seqNum)
        for(i in key.seqNum.idx) {
                dur.temp = duration(x.ts[(nona.seqNum[i - 1] + 1):(nona.seqNum[i] - 1),  ])
                ans[(nona.seqNum[i - 1] + 2):(nona.seqNum[i] - 1),  ] = cumsum(as.matrix(seriesData(dur.temp)
                        ))
        }
        ans = as.data.frame(ans)
        ans = timeSeries(ans, pos = x.pos)
}
Warning messages:
  Conflicting definitions of "aggregateSeries" on databases "C:\HFAnalysis" and  "splus"
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-19 10:57:09
谢谢epoh老师,听您一说,和R很相似,只要把HFLibrary.SSC放在对应目录下就可以了,再用source调用

module和library有何区别呢?
pkgutils这个包是一个大类吗?
install.pkgutils()和install.packages(""pkgutils)都可以吧?
呵呵,这台电脑没有那软件,回去我试下



ps:这个分析高频数据,在finmetrics目录下有一个supplement指导文件,里面有详细运行说明
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-19 10:59:54
epoh老师,经常听到高频数据,您能不能直观解释一下什么时候用高频数据?高频数据有什么特征呢?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-19 11:05:30
zhangtao 兄
HFLibrary.SSC一开始就已载入
就是用他的function TAQLoad()
读取trade_msft.txt,quote_msft.txt,...
到了reorderTS ()才会产生错误
而这个错误信息也不是reorderTS
而是function sub()造成
这是s-plus的基本function
有可能是新旧版本的不同所造成

finmetrics 3.0 已经不用reorderTS
而是用seriesReorder: Correct ordering of dates in timeSeries

finmetrics 3.0 已经不用plotByDays
而是用dayPlot: trellisPlot of timeSeries by days

##############
source("c:/HFAnalysis/HFLibrary.ssc")
## Load the FinMetrics module
module("finmetrics", first=F)
#################### Section 2 Data Proceesing ####################################
### loading MSFT Trade data ####
msftt.ts = TAQLoad(file = "C:/HFAnalysis/trade_msft.txt",type = "trade", sep = "|", skip = 1)
msftt.ts[1:5,]
slotNames(msftt.ts)
[email=msftt.ts@data[1:5]msftt.ts@data[1:5[/email], ]
[email=msftt.ts@positions[1:5]msftt.ts@positions[1:5[/email]]
### loading MSFT Quote data ###
msftq.ts = TAQLoad(file = "C:/HFAnalysis/quote_msft.txt",type = "quote", sep = "|", skip = 1)
msftq.ts[1:5,]
### loading GE Trade data ####
get.ts = TAQLoad(file = "C:/HFAnalysis/trade_ge.txt",type = "trade", sep = "|", skip = 1)
get.ts[1:5,]      
### loading GE Quote data ###
geq.ts = TAQLoad(file = "C:/HFAnalysis/quote_ge.txt",type = "quote", sep = "|", skip = 1)
geq.ts[1:5,]
### loading USD/EUR data ###
eurusd.ts = OlsenLoad("C:/HFAnalysis/eur_usd.txt")
eurusd.ts[1:5,]
eurusd.ts[1:5, "Bid"]
################# Plotting
bid.May2 = msftq.ts[timeEvent("5/2/1997 09:30:00", "5/2/1997 16:00:00"),"Bid"]
ask.May2 = msftq.ts[timeEvent("5/2/1997 09:30:00", "5/2/1997 16:00:00"),"Ask"]
plot(bid.May2,ask.May2, main="Microsoft Bid and Ask Quotes",plot.args=list(lty=c(1,1), col=c(2,5)))
legend(0, 120.5, legend=c("Bid","Ask"), lty=c(1,1), col=c(2,5))
graphsheet()
trellisPlot(bid.May2,ask.May2, main="Microsoft Bid and Ask Quotes")
graphsheet()
###single panel plot
bidAsk.ts = seriesMerge(bid.May2, ask.May2)
trellisPlot(bidAsk.ts)
graphsheet()
####
msftt.ts = seriesReorder(msftt.ts)
msftq.ts = seriesReorder(msftq.ts)
get.ts = seriesReorder(get.ts)
geq.ts = seriesReorder(geq.ts)
eurusd.ts = seriesReorder(eurusd.ts)
####Day plots
dayPlot(msftt.ts[timeEvent("5/1/1997","5/8/1997"),"Price"], type="p",scales=list(y=list(relation="free")))
graphsheet()
dayPlot(eurusd.ts[timeEvent("3/11/2001","3/17/2001"), "Bid"], type="p",scales=list(y=list(relation="free")))

##########
就改到这里供你参考.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-19 17:44:13
运行附件中matlab程序,有以下错误提示,epoh老师,您看如何修改呢?非常感谢!!!

??? Error: File: F:\0计量经济学前沿\BEKK\full_bekk_mvgarch.m Line: 4 Column: 1
Function definitions are not permitted at the prompt or in scripts.
附件列表

bekk111.rar

大小:3.66 KB

 马上下载

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-19 17:47:05
另外,请问epoh老师,在splus8中如何调用GARCH-BEKK进行估计?最好有个例子。
附件中是mgarch.ssc程序,我没有hp.s和ibm.s数据,如果您有,能给我吗?
另外,如何装入数据和运行?
非常感谢!
附件列表

mgarchssc.rar

大小:5.09 KB

 马上下载

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-19 18:58:13
我添加了ibm.s and hp.s数据,为什么还提示以下错误?为什么还提示找不到ibm.s?
附件中有数据和程序。
> # MGARCH.ssc
> # Prepared for the MGARCH Chapter
> # Date: April 5, 2002
>
> hp.ibm=seriesMerge(hp.s,ibm.s)
Problem: Object "ibm.s" not found
Use traceback() to see the call stack
> tmp=acf(hp.ibm^2)
附件列表

mgarchssc111.rar

大小:8.78 KB

 马上下载

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-19 19:34:01
s-plus
Modelling Financial Time Series with S-PLUS
page 516/1016

module("finmetrics")
hp.ibm = seriesMerge(hp.s, ibm.s)
hp.ibm=100*hp.ibm
hp.ibm.bekk = mgarch(hp.ibm~-1, ~bekk(1,1))
hp.ibm.bekk

Call:
mgarch(formula.mean = hp.ibm ~ -1, formula.var =  ~ bekk(1, 1))
Mean Equation: structure(.Data = hp.ibm ~ -1, class = "formula")
Conditional Variance Equation: structure(.Data =  ~ bekk(1, 1),class = "formula")

Coefficients:

       A(1, 1)          0.74486
       A(2, 1)         -0.34202
       A(2, 2)          0.47969
ARCH(1; 1, 1)    0.20091
ARCH(1; 2, 1)   -0.02610
ARCH(1; 1, 2)   -0.05714
ARCH(1; 2, 2)    0.41349
GARCH(1; 1, 1)  0.82645
GARCH(1; 2, 1)  0.12095
GARCH(1; 1, 2)  0.25594
GARCH(1; 2, 2)  0.70165
                        
%%%%%%%%%%%%%%%%matlab
load('hp_ibm.txt')
data=100*hp_ibm;
[parameters, loglikelihood, Ht, likelihoods, stdresid, stderrors, A, B, scores]  = full_bekk_mvgarch(data,1,1);
parameters

parameters =
    0.6971
   -0.3355
    0.5062
    0.1955
   -0.0242
   -0.0369
    0.4192
    0.8438
    0.1163
    0.2327
    0.6977


hp_ibm.txt

   
hp_ibm.txt
大小:(46.27 KB)

 马上下载

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-20 13:46:16
50# epoh

??? Error using ==> vech
MATRIXDATA must be a symmetric matrix
Error in ==> scalar_bekk_mvgarch at 68
startingparameters=[vech(CChol);alpha0;beta0];
Error in ==> full_bekk_mvgarch at 60
startingparameters=scalar_bekk_mvgarch(data,p,q,scalaropt);
Error in ==> Untitled at 3
[parameters, loglikelihood, Ht, likelihoods, stdresid, stderrors, A, B, scores]  = full_bekk_mvgarch(data,1,1);

epoh老师,您好!
我把您的命令做成untiled.m文件,然后运行,为什么会提示以上错误?得不出结果。
附件列表

666.rar

大小:18.06 KB

 马上下载

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-20 13:50:03
在命令窗口直接运行会提示以下错误:
>> load('hp_ibm.txt')
data=100*hp_ibm;
[parameters, loglikelihood, Ht, likelihoods, stdresid, stderrors, A, B, scores]  = full_bekk_mvgarch(data,1,1);
??? Error using ==> vech
MATRIXDATA must be a symmetric matrix

Error in ==> scalar_bekk_mvgarch at 68
startingparameters=[vech(CChol);alpha0;beta0];

Error in ==> full_bekk_mvgarch at 59
startingparameters=scalar_bekk_mvgarch(data,p,q,scalaropt);

>>
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-20 13:55:01
>> load('hp_ibm.txt');
data=100*hp_ibm;
[parameters, loglikelihood, Ht, likelihoods, stdresid, stderrors, A, B, scores]  = full_bekk_mvgarch(data,1,1);
parameters
??? Error using ==> vech
MATRIXDATA must be a symmetric matrix

Error in ==> scalar_bekk_mvgarch at 68
startingparameters=[vech(CChol);alpha0;beta0];

Error in ==> full_bekk_mvgarch at 59
startingparameters=scalar_bekk_mvgarch(data,p,q,scalaropt);

>>
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-20 13:59:36
function [parameters, loglikelihood, Ht, likelihoods, stdresid, stderrors, A, B, scores]  = full_bekk_mvgarch(data,p,q, BEKKoptions)
% PURPOSE:
%      To Estimate a full BEKK multivariate GARCH model.  ****SEE WARNING AT END OF HELP FILE****
%
%
% USAGE:
%      [parameters, loglikelihood, Ht, likelihoods, stdresid, stderrors, A, B, scores]  = full_bekk_mvgarch(data,p,q,options);
%
%
% INPUTS:
%      data          - A t by k matrix of zero mean residuals
%      p             - The lag length of the innovation process
%      q             - The lag length of the AR process
%      options       - (optional) Options for the optimization(fminunc)
%
% OUTPUTS:
%      parameters    - A (k*(k+1))/2+p*k^2+q*k^2 vector of estimated parameteters. F
%                         or any k^2 set of Innovation or AR parameters X,
%                         reshape(X,k,k) will give the correct matrix
%                         To recover C, use ivech(parmaeters(1:(k*(k+1))/2)
%      loglikelihood - The loglikelihood of the function at the optimum
%      Ht            - A k x k x t 3 dimension matrix of conditional covariances
%      likelihoods   - A t by 1 vector of individual likelihoods
%      stdresid      - A t by k matrix of multivariate standardized residuals
%      stderrors     - A numParams^2 square matrix of robust Standad Errors(A^(-1)*B*A^(-1)*t^(-1))
%      A             - The estimated inverse of the non-robust Standard errors
%      B             - The estimated covariance of teh scores
%      scores        - A t by numParams matrix of individual scores
%
%
% COMMENTS:
%    You should multiply the data by a constant so that the min std(data) is at least 10.  This will help estimation
%
%      ***************************************************************************************
%      *  THIS FUNCTION INVOLVES ESTIMATING MANY PARAMETERS.  THE EXACT NUMBER OF PARAMETERS
%      *  NEEDING TO BE ESTIMATED IS (k*(k+1))/2+pk^2+qk^2.  FOR A 5 VARIATE (1,1) MODEL THIS
%      *  65 PARAMETERS.  ESTIMATION CAN TAKE A VERY LONG TIME.  A 10 ASSET MODEL TOOK 12
%      *  HOURS ON A PIII-700.
%      ***************************************************************************************
%
%
% Author: Kevin Sheppard
% kevin.sheppard@economics.ox.ac.uk
% Revision: 2    Date: 12/31/2001

load('hp_ibm.txt');
data=100*hp_ibm;
[parameters, loglikelihood, Ht, likelihoods, stdresid, stderrors, A, B, scores]  = full_bekk_mvgarch(data,1,1);
parameters



% need to try and get some smart startgin values


??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit.  Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.

Error in ==> full_bekk_mvgarch at 49
[parameters, loglikelihood, Ht, likelihoods, stdresid, stderrors, A, B, scores]  = full_bekk_mvgarch(data,1,1);

>>

如果加在程序中,会提示以上错误。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-20 14:33:54
请注意:
matlab function 的内容,切勿任意更改
譬如function full_bekk_mvgarch()
内容,参数名,不能随意更改
所以你在full_bekk_mvgarch()
加了
  p=6;
  q=6;
这是不对的!
data 也不能改为data.txt
function [parameters, loglikelihood, Ht, likelihoods, stdresid, stderrors, A, B, scores]  = full_bekk_mvgarch(data.txt,p,q, BEKKoptions)

只要恢复原始的full_bekk_mvgarch()即可.


%%%%%%%%%%%%%
%%in command window
load('hp_ibm.txt')
data=100*hp_ibm;
[parameters, loglikelihood, Ht, likelihoods, stdresid, stderrors, A, B, scores]  = full_bekk_mvgarch(data,1,1);

%% or
Untitled


%%%%%%%%%%
%%%%%%%%%%
diagonal_bekk

%%%in matlab
load('hp_ibm.txt')
data=100*hp_ibm;
[parameters, loglikelihood, Ht, likelihoods, stdresid, stderrors, A, B, scores] = diagonal_bekk_mvgarch(data,1,1);
parameters
parameters =
    0.5193
    0.3217
    0.4065
    0.2106
    0.3349
    0.9491
    0.8665

%%%%%%%%%

in E-views

Convergence achieved after 39 iterations   
   
                   Coefficient Std. Error z-Statistic Prob.  
   
OMEGA(1)     0.518868 0.043023 12.06025 0.0000
BETA(1)         0.949176 0.006293 150.8325 0.0000
ALPHA(1)       0.210438 0.012218 17.22400 0.0000
OMEGA(3)     0.406375 0.023036 17.64115 0.0000
OMEGA(2)     0.321527 0.041833 7.685968 0.0000
BETA(2)         0.866632 0.014308 60.56796 0.0000
ALPHA(2)       0.334758 0.008604 38.90611 0.0000

eviews_hp_ibm_diag_bekk
  
eviews_hp_ibm.rar
大小:(23.83 KB)

 马上下载

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-20 16:15:15
55# epoh

我就是按您的指导做的,还是提示以下错误,我估计我用的matlab7版本太低,
所以会提示错误。

>> load('hp_ibm.txt')
data=100*hp_ibm;
[parameters, loglikelihood, Ht, likelihoods, stdresid, stderrors, A, B, scores]  = full_bekk_mvgarch(data,1,1);
??? Error using ==> vech
MATRIXDATA must be a symmetric matrix
Error in ==> scalar_bekk_mvgarch at 68
startingparameters=[vech(CChol);alpha0;beta0];
Error in ==> full_bekk_mvgarch at 59
startingparameters=scalar_bekk_mvgarch(data,p,q,scalaropt);
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-20 16:40:53
pls try diagonal_bekk_mvgarch()
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-20 16:45:21
epoh老师,您用的是diagonal_bekk_mvgarch.m文件,
我传上去的是full_bekk_mvgarch.m文件,我们用的不是同一个文件,
所以会产生以上错误,是不是这个原因呢?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-20 16:53:08
Undefined symbols:
    _mlhsvcp                           C:\MGARCH\MGARCH.GS(512)
还想您请教一个问题:附件中的gauss 程序运行时为什么会提示以上问题?
附件列表

MGARCH.rar

大小:83.31 KB

 马上下载

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2011-7-20 19:14:26
MGARCH.GS的确存在一些问题

不过我想先了解一下
你不会单独只用full_bekk_mvgarch.m 一个file 吧
应该有装jplv7 toolbox
或最起码装上 Ucsd_garch toolbox 吧

如果都有装上
而存在问题的话,我再帮你想办法.设置startingparameters
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群