Displaying 1 result from an estimated 1 matches for "nomig".
Did you mean:
nomis
2006 Nov 05
1
diag()<- in Matrix?
...s on rather
large and sparse matrices. An example of such a matrix is given below.
mig<-0.2
side<-10
np<-side^2
mig.mat<-matrix(0,np,np)
diag(mig.mat[1:(np-side),(side+1):np])<-mig/4
diag(mig.mat[(side+1):np,1:(np-side)])<-mig/4
diag(mig.mat[-np,-1])<-mig/4
nomig<-which(1:(side^2-1)%%side==0)
diag(mig.mat[-np,-1])[nomig]<-0
diag(mig.mat[-1,-np])<-mig/4
diag(mig.mat[-1,-np])[nomig]<-0
diag(mig.mat)<-1-apply(mig.mat,2,sum)
Here, side is set to 10, but ideally, I'd like it to be 500.
I tried to simply replace matrix by Matrix in t...