楼主: cjqazy123
4834 0

[问答] Error in solve.default(-val) : Lapack routine dgesv: system is exactly singul [推广有奖]

  • 1关注
  • 1粉丝

硕士生

3%

还不是VIP/贵宾

-

威望
0
论坛币
277 个
通用积分
0.0110
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
246 点
帖子
23
精华
0
在线时间
180 小时
注册时间
2014-3-25
最后登录
2020-3-10

楼主
cjqazy123 学生认证  发表于 2016-9-15 22:54:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
各位前辈好!

我最近在做价格传导,利用作者原有的数据和写好的语法跑了一遍模型(TVECM),但是一直提示如下错误,请问是怎么回事?需要如何解决呢?R语言新手菜鸟,希望各位大神指点一二,感激不尽!
> library(nlme)
>
> # load data
>
> A <- read.table(file="eu-pigs.dat")
> colnames(A) <- c("BE", "DK", "BRD", "E", "FR", "I", "NL")
> Y <- rbind(A$BRD,A$E)
>
> # specify number of lags to be included in the TVECM
>
> lags <- 3
>
> # calculate the error correction term as the price difference
>
> z <- Y[1,]-Y[2,]
>
> # organize data
>
> N <- length(z)
> Delta.Y <- Y[,-1]-Y[,-N]
>
> mat <- matrix(NaN,2*(lags+2)+1,N+lags+1)
> mat[1:2,1:N] <- Y
> mat[3:4,2:N] <- Delta.Y
> mat[5,2:(N+1)] <- z
> for (l in 1:lags){
+ mat[(2*l+4):(2*l+5),(2+l):(N+l)] <- Delta.Y
+ }
> mat <- mat[,which(!is.nan(colSums(mat)))]
>
> Y <- mat[1:2,]
> Delta.Y <- mat[3:4,]
> y <- c(Delta.Y[1, ],Delta.Y[2, ])
> z <- mat[5,]
> x <- t(mat[5:(2*(lags+2)+1),])
> x <- cbind(1,x)
>
> p <- ncol(x)
> N <- nrow(x)
>
> # specify grid
>
> grid <- sort(unique(z))
> grid1 <- grid[which(grid<0)]
> grid2 <- grid[which(grid>0)]
>
> G1 <- length(grid1)
> G2 <- length(grid2)
>
> # evaluate profile likelihood/posterior density on grid
>
> LF1 <- LF2 <- LF3 <- LF4 <- matrix(NaN,G1,G2)
>
> for (n in 1:G1)
+ {
+ for (m in 1:G2)
+ {
+ psi.1 <- grid1[n]
+ psi.2 <- grid2[m]
+ X <- kronecker(diag(1,2,2),x)
+ X1 <- kronecker(diag(1,2,2),(z <= psi.1)*x)
+ X2 <- kronecker(diag(1,2,2),(z > psi.1 & z <= psi.2)*x)
+ X3 <- kronecker(diag(1,2,2),(z > psi.2)*x)
+ Xpsi <- cbind(X1,X2,X3)
+
+ # compute profile likelihood
+
+ if (sum(z <= psi.1)>=p & sum(z > psi.1 & z <= psi.2)>=p & sum(z > psi.2)>=p)
+ {
+ ## same variance for the two components of the series (in effect, least squares)
+
+ LM <- lm(y ~ Xpsi-1)
+ LF1[n,m] <- logLik(LM)
+
+ ## different variances for the two components of the series
+
+ SSE <- matrix(LM$res,nrow=2,byrow=TRUE)
+ SSE1 <- sum((SSE[1,])^2)
+ SSE2 <- sum((SSE[2,])^2)
+ LF2[n,m] <- -log(SSE1*SSE2)
+ }
+
+ # compute regularized Bayesian posterior
+
+ ## same variance for the two components of the series
+
+ group.vector <- factor(rep(1,(2*N)))
+ ZBlock <- list(list(group.vector=pdIdent(~ X1-1)),list(group.vector=pdIdent(~ X2-1)))
+ ZBlock <- unlist(ZBlock,recursive=FALSE)
+ try({LME <-  lme(y ~ X - 1, random=ZBlock)
+ LF3[n,m] <- LME$logLik})
+
+ ## different variances for the two components of the series
+
+ group <- rep(1:2,each=N)
+ try({LMEnew <- update(LME, weights=varIdent(form =  ~ 1|group))
+ LF4[n,m] <- LMEnew$logLik})
+ }}
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0
Error in lme.formula(y ~ X - 1, random = ZBlock) :
  nlminb problem, convergence error code = 1
  message = singular convergence (7)
Error in solve.default(-val) :
  system is computationally singular: reciprocal condition number = 5.86726e-24
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0
Error in solve.default(-val) :
  Lapack routine dgesv: system is exactly singular: U[2,2] = 0



二维码

扫码加我 拉你入群

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

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

关键词:Routine exactly Default System Lapack Lapack routine system exactly singular

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-9 03:49