[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] 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] 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] 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.


[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 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] Logistic regression help!

2014-05-03 Thread Si Qi L.
Hi guys, I have a trouble to solve the specificity and senstitivity
for a logistic regression model. I really need your help, would you
please help me out? :) Thank you!!

This is the model I constructed:

model=glm(Status ~ Gender.compl+ X2.4.times.per.month+ 
Once.a.month+Others+Council.tenant+Living.with.friends.family+Living.with.parents+Owner.occupier+Private.tenant+X1.year.to.2.years+X2.to.4.years+X3.months.to.a.year+Less.than.3.months+Over.4.years+Emp.compl+Reqloanamount+EmpNetMonthlyPay+Customer_Age+RTI+acc.compl+iic.compl+irb.compl+jbc.compl+jic.compl+jq.compl+kic.compl+lbc.compl+mbc.compl+njc.compl+or.compl+pq.compl+pr.compl+qic.compl+teb.compl+tpb.compl+vbc.compl+yzb.compl+zr.compl,
 data=learning.set1, family=binomial)

so how to compute the sensititvity and specitivity? Many thanks!

Siqi

__
R-help@r-project.org mailing list
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] About Tree Package

2014-04-28 Thread Si Qi L.
Hi,

I will be very grateful if you can give a help on my problem. I am
really stuck on it now. The problem is that I need to construct a
classification tree model and prune tree in order to test the learning
dataset for getting its sensitivity and specificity. But my codes
seems wrong somewhere, will you guys please help me out? Many
thanks!:D

These are codes:

library(tree)
attach(learning.set1)
Status.f- factor(Status)

tree1-tree(Status.f  ~ Gender.compl+ X2.4.times.per.month+
Once.a.month+Council.tenant+Living.with.friends.family+Living.with.parents+Owner.occupier+X1.year.to.2.years+X2.to.4.years+X3.months.to.a.year+Less.than.3.months+Empl.compl+Reqloanamount+EmpNetMonthlyPay+Customer_Age+RTI+acc.compl+iic.compl+irb.compl+jbc.compl+jic.compl+jq.compl+kic.compl+lbc.compl+mbc.compl+njc.compl+or.compl+pq.compl+pr.compl+qic.compl+teb.compl+tpb.compl+vbc.compl+yzb.compl+zr.compl,
method=class, data=learning.set1, split=gini)

summary(tree1)
print(tree1)
plot(tree1)
text(tree1)
pfit-prune.tree(tree1,
k=tree1$cptable[which.min(tree1$cptable[,xerror]),CP])
plot(pfit, uniform=TRUE)
text(pfit)
pred-predict(tree1,learning.set1,type=vector)
table1-table(learning.set1$Status,predict(tree1,type=vector))
 table1

   01

  0 1429  108

  1  273  164

sum-sum(learning.set1$Status==pred)/length(pred)
sens- function(table1) { table1[2,2] / sum(table1[,2]) }
spec- function(table1) { table1[1,1] / sum(table1[,1]) }
myt-matrix(c(1429,273,108,164), ncol=2)
sens
spec

__
R-help@r-project.org mailing list
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] sensitivity and specificity

2014-04-25 Thread Si Qi L.
Hi guys,

I will be very grateful if you guys can do me a little favor on R. I am
calculating the sensitivity and specificity for a 2*2 matrix, such as

 t
   01
  0 1427  110
  1  271  166



My codes are:   sens - function(ct) { ct[2,2] / sum(ct[,2]) }
  spec - function(ct) { ct[1,1] / sum(ct[,1]) }

But it doesn't show any numerical results. Would you please help me to fix
it? Mnay thanks for your help.:)

Best regards,

Siqi

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] logistical indexing in R

2014-04-09 Thread Si Qi L.
Dear mates,

I am bit of stuck with a coding, all I have to do is to clean and tranform
the missing data -97 of the attribute ej into a normal number value
in a range from 0 to 22. My steps are :

1) first return the subsets, as check, they do sum to original
2) manipulate the attribute ej separately and replace them

# assuming you have done one round of cleaning now and saved the result in
 a file called test.csv.

data-read.csv(test.csv, header=T)
 data1 - subset(data, ej==-97)
summary(data1)

# ND now listed as an Other field
data2 - subset(data, ej!=-97)
summary(data2)
# can store the contents of ej and copy them back into data1 and data2.
# or just operate on them directly;
vector_with_ej - data1$ej
vector_without_ej - data2$ej

So, How to do next? can anyone please give me some comments? Many thanks!

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


Re: [R] about lm()

2014-03-31 Thread Si Qi L.
Hi,

I am very new on R so I will remember to post in plain text next time.
Thank you all for your help. I think I can figure it out now~ Many thanks!:)

Best regards,

Siqi


2014-03-31 11:43 GMT+01:00 Helios de Rosario helios.derosa...@ibv.upv.es:

  El día 30/03/2014 a las 15:23, Si Qi L. liusiqi.n...@gmail.com
  escribió:
  Hi
 
  I have a problem with linear regression. This is my codes:
 
  acc1- lm(data$acc ~ dummy + data$Reqloanamount + data$Code +
  data$Code.1 +
  data$EmpNetMonthlyPay + data$Customer_Age + data$RTI)
  summary(acc1)
 
  These attributes are all numerical except the acc(factors), so how
 can I
  fix the problem R showed me? can anyone please help me out? Many
  thanks!
 

 If you want to fit a model with a factor dependent variable, you should
 not use lm(). Perhaps you are looking for ?glm (family binomial) if it
 is binomial data, or ?polr (in package MASS), ?multinom (in nnet), or
 ?clm and others (in ordinal) if the variable has more than two levels.

 Helios De Rosario

 INSTITUTO DE BIOMECÁNICA DE VALENCIA
 Universidad Politécnica de Valencia * Edificio 9C
 Camino de Vera s/n * 46022 VALENCIA (ESPAÑA)
 Tel. +34 96 387 91 60 * Fax +34 96 387 91 69
 www.ibv.org

   Antes de imprimir este e-mail piense bien si es necesario hacerlo.
 En cumplimiento de la Ley Orgánica 15/1999 reguladora de la Protección
 de Datos de Carácter Personal, le informamos de que el presente mensaje
 contiene información confidencial, siendo para uso exclusivo del
 destinatario arriba indicado. En caso de no ser usted el destinatario
 del mismo le informamos que su recepción no le autoriza a su divulgación
 o reproducción por cualquier medio, debiendo destruirlo de inmediato,
 rogándole lo notifique al remitente.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] about lm()

2014-03-30 Thread Si Qi L.
Hi

I have a problem with linear regression. This is my codes:

acc1- lm(data$acc ~ dummy + data$Reqloanamount + data$Code + data$Code.1 +
data$EmpNetMonthlyPay + data$Customer_Age + data$RTI)
summary(acc1)

These attributes are all numerical except the acc(factors), so how can I
fix the problem R showed me? can anyone please help me out? Many thanks!

But the R shows:

Residuals:Error in quantile.default(resid) : factors are not allowedIn
addition: Warning message:In Ops.factor(r, 2) : ^ not meaningful for
factors

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] dummy coding problem

2014-03-26 Thread Si Qi L.
Hi, I have got a problem with dummy coding and I really couldn't figure it
out. Would you please help me out? this is my codes:

idx-sort(unique(Employment.time$V1));
dummy - matrix(NA, nrow=nrow(Employment.time), ncol= length(idx))

for (i in 1:nrow(Employment.time)) {

for (j in 1:length(idx)) {

if (Employment.time$V1[i,j] == Over 4 years) {
dummy[i,j] - 0
}
else {
dummy[i,j] - 1
}
}
}

but the R shows that

Error in `[.default`(Employment.time$V1, i, j) :
incorrect number of dimensions

Do you know where is wrong? many thanks!

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] How to creat a dummy coding in R? (URGENT!)

2014-03-25 Thread Si Qi L.
Hi, it's so urgent that I really need your help on R. This following is
part of my data, do u know how to create a dummy coding about it in R? My
control group is Owner occupier. Many thanks for your big help!!!:)

*AppHomeStatus*
Owner occupier
Living with parents
Living with parents
Private tenant
Private tenant
Private tenant
Council tenant
Owner occupier
Owner occupier
Living with friends/family

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] DUD (Does not Use Derivatives) for nonlinear regression in R?

2013-04-01 Thread qi A
Hi, All

SAS has DUD (Does not Use Derivatives)/Secant Method for nonlinear
regression, does R offer this option for nonlinear regression?

I have read the helpfile for nls() and could not find such option, any
suggestion?

Thanks,

Derek

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] Is DUD available in nls()?

2013-04-01 Thread qi A
SAS has DUD (Does not Use Derivatives)/Secant Method for nonlinear
regression, does R offer this option for nonlinear regression?

I have read the helpfile for nls() and could not find such option, any
suggestion?

Thanks,

Derek

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] R help

2012-08-08 Thread chong hui qi
Hi 

 

I'm trying to increase the memory limit but Im facing this problem 

Error: unexpected symbol in C:\\Program
Files\\R\\R-2.15.0\\bin\\i386\\Rgui.exe --max-mem-size=500M 

 

Hope you can help me out 

Thank You 

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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] Warning message when Loading package svMisc in R 2.10.0

2009-10-27 Thread Qi Li
Hi,

I have a problem when using R 2.10.0,

Loading required package: svMisc
Warning message:
package 'svMisc' was built under R version 2.9.1 and help will not work 
correctly

HOW to fix it? 
__
R-help@r-project.org mailing list
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] Tinn-R (Version 2.2.0.2) dose not support R 2.9.0 very well

2009-04-17 Thread LI Qi
Hi£¬

I found that Tinn-R (Version 2.2.0.2) dose not support R 2.9.0 very well. 
Maybe, somebody who have solved this problem can help me.

Thanks for your attention!
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.