全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
1819 1
2016-05-21
悬赏 5 个论坛币 未解决
本人利用门限模型做的门槛分别是0.11,0.19,0.40,我打算调整程序使得门槛之间的值大于0.1,也就是希望能够生成门槛为0.11和0.40,或者0.19和0.40.  需要修改Trimming Percentage吗,但是试了好几遍,都无法实现。求大神帮忙,谢谢!!!程序如下:
data <- read.csv("data12_1.csv")
t <- 9                        
nt <- nrow(data)            
n <- nt/t                     

fp <- data[,5]              
yf <- data[,7]                                 
d  <- data[,8]  
zb <- data[,10]
zc <- data[,11]  
dd <- data[,12]
wx <- data[,13]

qn <- 150          # number of quantiles to examine               
conf_lev <- 0.95   # confidence level for threshold               
vgraph <- 1        # set to 1 to graph likelihood ratios           
boot_1 <- 300      # number of replications, 0 for no bootstrap, single (300)
boot_2 <- 200     # number of replications, 0 for no bootstrap, double (300)
boot_3 <- 200      # number of replications, 0 for no bootstrap, triple (300)
boot_4 <- 200
trim_1 <- 0.02     # percentage to trim before search, single      
trim_2 <- 0.1    # percentage to trim before search, double      
trim_3 <- 0.1     # percentage to trim before search, triple      
trim_4 <- 0.1     ####

max_lag <- 1
tt <- t-max_lag
ty <- n*(t-max_lag-1)

lag_v <- function(x,lagn){
      yl <- matrix(c(0),nrow=n,ncol=t)
      for (i in 1:n) {
          yl[i,]<-x[(1+(i-1)*t):(t*i)]
      }  
      yl <- yl[,(1+max_lag-lagn):(t-lagn)]
      out <- matrix(t(yl),nrow=nrow(yl)*ncol(yl),ncol=1)
      out
}

tr <- function(y){
   yf <- matrix(c(0),nrow=n,ncol=tt)
   for (i in 1:n) {
       yf[i,]<-y[(1+(i-1)*tt):(tt*i)]
   }
   yfm <- yf- colMeans(t(yf))
   yfm <- yfm[,1:(tt-1)]
   out <- matrix(t(yfm),nrow=nrow(yfm)*ncol(yfm),ncol=1)
   out
}

y  <- lag_v(fp,0)#
yff <- lag_v(yf,1) #
zb1 <- lag_v(zb,1)#
zc1 <- lag_v(zc,1)#
dd1 <- lag_v(dd,1)#
wx1 <- lag_v(wx,1)#
d1 <- lag_v(d,1)   # set to threshold variable
yt <- tr(y)#
ct <- tr(yff)
二维码

扫码加我 拉你入群

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

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

全部回复
2016-5-22 18:02:41
楼主能把门限模型的代码和资料发我吗,3105046469@qq.com
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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