说原因也只能是对自己呵呵了,在法国留学回来,选的硕士论文时关于中国股票市场的稳定分布的,因为是系主任指定用R语言来写,对于一个金融学本科,从没碰过quantitive的汉子也是醉了。话不多说,在求证很多数据后,碰到了一个难题,因为R语言又更新来,导师给的参考方法论还是2011年,结果有些function换了。
现在假设我们选取 上证 600219.SS作为对象,我的流程是这样的,
install.packages('tseries')
library('tseries')
install.packages('e1071')
library('e1071')
install.packages('NORMT3')
library('NORMT3')
install.packages('VGAM')
library('VGAM')
install.packages('ADGofTest')
library('ADGofTest')
install.packages('fBasics')
library('fBasics')
install.packages('MASS')
library('MASS')
install.packages('timeDate')
library('timeDate')
NS<-get.hist.quote("600219.SS",quote="Close",start = "2000-01-03",end="2015-03-25",compression="d") # this is the stock i choose for example, NS, ticker is 600219 from shanghai stock exchange
num_of_quotes <- nrow(data)
daily_changes <- diff(log(NS))
plot(data$Close,type="l")
plot(daily_changes,type="l")
summary(daily_changes)
quantile(daily_changes)
skewness(daily_changes)
kurtosis(daily_changes)
fitdistr(daily_changes,"normal")
mec <- mean(daily_changes)
sdc <- sd(daily_changes)
ad.test(daily_changes,pnorm,mec,sdc)
fitdistr(exp(mec+sdc*daily_changes),"lognormal")
(cauchy_fit <- fitdistr(daily_changes,"cauchy"))
cf_l <- cauchy_fit$estimate[1]
cf_s <- cauchy_fit$estimate[2]
ad.test(daily_changes,pcauchy,cf_l,cf_s)
laplace_fit <- vglm(daily_changes~1,laplace,data.frame(daily_changes),trace=TRUE,crot="l")
Coef(laplace_fit)
lf_l <- Coef(laplace_fit)[1]
lf_s <- Coef(laplace_fit)[2]
ad.test(daily_changes,plaplace,lf_l,lf_s)
(在做下面这一块时,泪流
,所有的证明都靠着这个了,结果就显示无等高值 )
> (stable_fit <- stableFit(daily_changes)) #Error in contour.default(alpha, beta, Phi2, levels = phi2, add = TRUE,
> sf_a <- stable_fit@fit$estimate[1]
> sf_b <- stable_fit@fit$estimate[2]
> sf_g <- stable_fit@fit$estimate[3]
> sf_d <- stable_fit@fit$estimate[4]
ad.test(daily_changes,pstable,sf_a,sf_b,sf_g,sf_d)
我就是想知道这四个值,alpha,beta,gamma,delta,你们大家有好的方法吗?因为时间比较赶了,还请各位大拿们琢磨琢磨,或者你有更好的r算法,可以有解答过程,万分感谢,
对于stabledist, 和stablemode 也都试过,不知怎么下手
我导师的范例,http://snipplr.com/view/58647/analysis-of-the-stock-market-daily-returns-distribution-based-on-wig20-index/
他应该是自己导的数据,我看他时csv格式的。
求解答啊!