0

I have four matrices of one multigraph, like this:

> 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

I rearrange it's with ...

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)

when i perform "netlm" command, the next message appears:

"Error in netlm(projects, x, reps = 100) : Homogeneous graph orders required in netlm."

How can I fix it? Thanks

Sebastián
  • 111
  • 8

2 Answers2

1

The problem here is that netlm expects a list rather than an array, so I think it is not reading the entries as separate networks. The error indicates as much. It is not seeing three 5x5 matrices. Use list() instead.

nets <- rgraph(5,4)
y <- nets[1,,]
info <- nets[2,,]
infra <- nets[3,,]
prob <- nets[4,,]

Now, you can use list() in the netlm() command itself (saves a step):

nl <- netlm(y,list(info,infra,prob),reps=100)

Or you can create the list as an object and use it that way:

x <- list(info,infra,prob)
nl <- netlm(y,x,reps=100)

Since you have three separate networks already, you can just do:

nl <- netlm(projects,list(problems, information, infrastructure),reps=100)
paqmo
  • 3,649
  • 1
  • 11
  • 21
  • Thank you @paqmo. I had already solved by correcting the array. Anyway, your solution seems better. I take this opportunity to ask how to get the t-statistic instead of the regression coefficient, given the possible biases of heteroscedasticity, as was exposed by Lindgren (2010) – Sebastián Oct 15 '16 at 19:56
  • t-stat is pretty easy to get. It's contained in the `netlm()` object. Simply call `nl$tstat` and you'll get them! Incidentally, if you are interested in correcting for heteroscedasticity as Lindgren recommends (you may already know this), you can recover the original OLS estimate by using the `gvectorize` command in the `sna` package to turn the matrix into a vector. Then run `lm()`. So in this case: `lm(gvectorize(y) ~ gvectorize(info) + gvectorize(infra) + gvectorize(prob))`. You could correct for heteroscedastic errors there and then ran the permutations yourself. – paqmo Oct 15 '16 at 20:45
  • Thank you very much, @paqmo. – Sebastián Oct 16 '16 at 23:44
0

I made a mistake in defining the array, I should write the following code: array(NA,c(3,length(infrastructure[1,]),length(infrastructure[,1])))

Sebastián
  • 111
  • 8