我有一个多图的四个矩阵,如下所示:
> projects
1 2 3 4 5
1 0 0 4 1 0
2 0 0 3 2 5
3 0 0 0 0 0
4 0 0 0 0 1
5 0 0 0 0 0
> infrastructure
1 2 3 4 5
1 0 0 0 5 0
2 0 0 4 0 0
3 0 0 0 2 2
4 0 0 0 0 3
5 0 0 0 0 0
> information
1 2 3 4 5
1 0 1 3 0 0
2 0 0 2 3 4
3 0 0 0 0 0
4 0 0 0 0 0
5 0 0 0 0 0
> problems
1 2 3 4 5
1 0 1 0 1 0
2 0 0 0 0 0
3 0 0 0 1 1
4 0 0 0 0 0
5 0 0 0 0 0我把它和.
x <- array(NA, c(length(infrastructure[1,]),length(infrastructure[,1]),3))
x[,,1] <- infrastructure
x[,,2] <- information
x[,,3] <- problems
nl <- netlm(projects,x,reps=100)当我执行"netlm“命令时,将显示下一条消息:
netlm中的错误(projects,x,reps = 100):netlm所需的同构图顺序。
我怎么才能修好它?谢谢
发布于 2016-10-12 14:38:03
这里的问题是netlm需要一个列表而不是一个数组,所以我认为它不是将条目作为单独的网络来读取。这个错误也说明了这一点。它没有看到三个5x5矩阵。使用list()代替。
nets <- rgraph(5,4)
y <- nets[1,,]
info <- nets[2,,]
infra <- nets[3,,]
prob <- nets[4,,]现在,您可以在list()命令本身中使用netlm() (保存一个步骤):
nl <- netlm(y,list(info,infra,prob),reps=100)或者您可以将列表创建为一个对象并以这样的方式使用它:
x <- list(info,infra,prob)
nl <- netlm(y,x,reps=100)由于您已经有了三个独立的网络,所以您可以这样做:
nl <- netlm(projects,list(problems, information, infrastructure),reps=100)发布于 2016-04-08 12:50:15
我在定义数组时犯了错误,我应该编写以下代码:array(NA,c(3,length(infrastructure[1,]),length(infrastructure[,1])))
https://stackoverflow.com/questions/36486450
复制相似问题