首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当一个对象中存在多个列时,两个对象的列长度

当一个对象中存在多个列时,两个对象的列长度
EN

Stack Overflow用户
提问于 2014-01-22 00:58:04
回答 1查看 31关注 0票数 0

我有以下向量和acf函数( quantmod包、XML包、动物园包)

代码语言:javascript
复制
L<- 1
theurl <- "http://www.iasg.com/groups/group/transtrend/program/transtrend-diversified-   
trend-program-enhanced-risk-usd"
tables <- readHTMLTable(theurl)
n.rows <- unlist(lapply(tables, function(t) dim(t)[1]))
MONTHLYPERFORMANCE<-tables[[which.max(n.rows)]]
z<- as.data.frame(MONTHLYPERFORMANCE);
z$Year<-NULL
z$YTD <- NULL
z$DD <- NULL
z <- z[nrow(z):1,];
s<-as.vector(t(z))
w<-as.numeric(s)
p<-na.omit(w)
x<-(p*0.01*L)
d<-length(na.omit(x)) 
x<- x[1:d]  
#DETREND+DENOISE
s<-detrend(x, tt = 'linear', bp = c())
#AUTOCORRELATION
a<-acf(x)
b<-a[[1]]   
c<-(b[2:length(b)])
posssignificance_level<-qnorm((1+0.95)/2)/sqrt(sum(!is.na(x)))
posssignificance_level
negsignificance_level<- -posssignificance_level
negsignificance_level
poscorr<-which(posssignificance_level<c)
negcorr<-which(negsignificance_level>c)
posautorrelation <- if(length(poscorr) == 0) Lag(s,0) else na.omit(posautorrelation <-  
Lag(s, poscorr))
negautorrelation <- if(length(negcorr) == 0) Lag(s,0) else na.omit(negautorrelation <-  
Lag(s, negcorr))

然后,我想使所有由偏序关系和否定自动关系产生的级数由下面的表达式获得最小行数,无论是从偏序关系还是从否定自动关系。

代码语言:javascript
复制
shortest <- min(length(posautorrelation), length(negautorrelation))
posautorrelation <- tail(posautorrelation, shortest)
negautorrelation <- tail(negautorrelation, shortest)
tpos <-na.omit(posautorrelation); rownames(tpos)<-NULL
tneg <-na.omit(negautorrelation); rownames(tneg)<-NULL

这很好,当我只有一个系列的积极和另一个消极。但是,如果“偏序关系”或“否定自动关系”产生多个列,则最短函数之和不同列的行数,从而妨碍“最短”表达式。是否有一种“最短”的方法来考虑后自动关系的一个列和否定关系的一个列。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-22 01:18:21

代码语言:javascript
复制
shortest <- min(length(posautorrelation[,1]), length(negautorrelation[,1]))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21272185

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档