[R] highfrequency package-jump test

2020-10-09 Thread Zixuan Qi
Hello,

My programming is as follows.

library(highfrequency)
library(data.table)
library(xts)
tm<-seq.POSIXt(from = as.POSIXct("2020-08-20 09:30:00"),to = 
as.POSIXct("2020-08-20 15:59:00"),by='min')
data<-xts(x=data$PRICE,order.by=tm)
data <- as.data.table(data)
setnames(data,c('index'),c('DT'))
setnames(data,c('V1'),c('PRICE'))
LMtest <- intradayJumpTest(pData = data,volEstimator = "RM", driftEstimator = 
"none",RM = "bipower", lookBackPeriod = 20,on = 'minutes', k = 5, marketOpen = 
"09:30:00",marketClose = "15:59:00")
plot(LMtest)

However, the error is that ''Error in xy.coords(x, y, setLab = FALSE) : 'x' and 
'y' lengths differ''. I don't know how to correct it.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] high-frequency data in R

2020-11-24 Thread Zixuan Qi
Hello,

I attach the sample data in the email and you can use the data to try my code.
My code is as follow.

library('highfrequency')
library('xts')
data=read.table("sample data.csv",header=F,skip = 
1,stringsAsFactors=FALSE,sep="\t")
colnames(data)=c(" ",'SYMBOL',"PRICE","PERMNO")
id <- unique(data$PERMNO)
mydata <- data.frame()
for (i in id){
  tmp <-data[data$PERMNO==i,]
  row.names(tmp)=tmp[,1]
  tmp=tmp[,-1]
  tmp.xts <- as.xts(tmp, order.by=as.POSIXlt(rownames(tmp),format="%Y/%m/%d 
%H:%M"))
  mydata <- rbind(mydata,tmp.xts)
}

The problem is that when I try to program tmp.xts <- as.xts(tmp, 
order.by=as.POSIXlt(rownames(tmp),format="%Y/%m/%d %H:%M")), then I get NaN 
rownames. I don't know why.

Thanks very much.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] 回复: high-frequency data in R

2020-11-24 Thread Zixuan Qi
DATESYMBOL  price   permno
10/1/2019 9:30  AA  93.26   24109
10/1/2019 9:31  AA  93.44   24109
10/1/2019 9:32  AA  93.44   24109
10/1/2019 9:33  AA  93.28   24109
10/1/2019 9:34  AA  93.37   24109
10/1/2019 9:35  AA  93.37   24109
10/1/2019 9:36  AA  93.33   24109
10/1/2019 9:30  AA  114.47  10138
10/1/2019 9:32  AA  114.22  10138
10/1/2019 9:33  AA  114.26  10138
10/1/2019 9:34  AA  114.27  10138
10/1/2019 9:35  AA  114.01  10138
10/1/2019 9:36  AA  114.07  10138
10/1/2019 9:37  AA  114.39  10138
10/1/2019 9:38  AA  114.32  10138
The sample data is here.

��: Zixuan Qi
ʱ��: 2020��11��25�� 4:12
�ռ���: r-help@r-project.org 
: high-frequency data in R

Hello,

I attach the sample data in the email and you can use the data to try my code.
My code is as follow.

library('highfrequency')
library('xts')
data=read.table("sample data.csv",header=F,skip = 
1,stringsAsFactors=FALSE,sep="\t")
colnames(data)=c(" ",'SYMBOL',"PRICE","PERMNO")
id <- unique(data$PERMNO)
mydata <- data.frame()
for (i in id){
  tmp <-data[data$PERMNO==i,]
  row.names(tmp)=tmp[,1]
  tmp=tmp[,-1]
  tmp.xts <- as.xts(tmp, order.by=as.POSIXlt(rownames(tmp),format="%Y/%m/%d 
%H:%M"))
  mydata <- rbind(mydata,tmp.xts)
}

The problem is that when I try to program tmp.xts <- as.xts(tmp, 
order.by=as.POSIXlt(rownames(tmp),format="%Y/%m/%d %H:%M")), then I get NaN 
rownames. I don't know why.

Thanks very much.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] A Question about MLE in R

2020-07-22 Thread Zixuan Qi
Hi,

I encounter a problem. I use optim() function in R to estimate likelihood
function and the method is SANN in the optim function.
out <-
optim(parm,logLik,method='SANN',hessian=T,control=list(maxit=500))

However, I find that each time I run the program, I will get different
values of parameters. My initial values are same, but the number of
iterations has reached the maximum limit. I expanded the number of
iterations to 5 million, but it��s still wrong.

I want to know what I should do. Is anyone willing to help me? Thanks so
much!

Best,
Cisy

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] A question about optim function in R

2020-07-26 Thread Zixuan Qi
Hi,

I encounter a problem in R. My program is as follows.
lower <- c(-Inf,-Inf,-Inf,-Inf,0,0,0,-1,-1,-1)
upper <- c(Inf,Inf,Inf,Inf,Inf,Inf,Inf,1,1,1)
out <- 
optim(parm,logLik,method='L-BFGS-B',lower=lower,upper=upper,hessian=hessian)

As you can see, I have restricted parameter[5], parameter[6] and parameter[7] 
to be greater than 0, but the program error is shown in the attached picture 
('产生' means 'produce'). The reason for this error seems to be the limit in the 
function does not work. I don't know why.

Can you help me? Thanks very much!.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] A question about nlminb function

2020-07-26 Thread Zixuan Qi
Hi,

I use the function nlminb to maximize a function and got convergence with the 
message false-convergence. I know the reason may be the gradient $B"`(Bf(x) 
may be computed incorrectly, the other stopping tolerances may be too tight, or 
either f or $B"`(Bf may be discontinuous near the current iterate x.

However, I want to know how to modify the program after this problem occurs.

Thanks very much.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.