identify peers within a firm - sparse matrix only
2 ビュー (過去 30 日間)
古いコメントを表示
Dear all:
This is a follow-up post from my previous one, which has been solved by @Image Analyst. Now I have encountered a new problem as I have increased my sample size by a lot.
The original problem is described as follows. The dataset contains worker ID and firm ID in each year. I hope to create a matrix that shows whether worker j is worker i's coworker. For example, if there are 5 workers and 2 firms in the dataset, the data structure look like below.
IDw IDf
1 1
2 2
3 1
4 2
5 2
Ideally, I hope to create a matrix C as follows:

As suggested by @Image Analyst, I could use the following code to create such a matrix:
firm2 = [firms(:), firms(:)];
distances = pdist2(firm2, firm2) == 0;
However, the code pdist2 requires a non-sparse matrix first. In my current case, it is a 0.7 million x 0.7 million matrix. My MATLAB could not handle such a matrix if it is non-sparse.
Therefor, I am wondering if anyone knows an alternative (quick) algorithm that could help me get a sparse matrix of C?
Thank you very much and I look forward to hearing from you!
Best,
Long
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!