如何使用R计算Multilpe回归二次分配程序?

时间:2017-05-11 09:16:29

标签: python r regression sna

我正在遵循本教程的多元回归 - 二次分配程序http://www.umasocialmedia.com/socialnetworks/lecture-9-patterns-in-social-networks/。它用于研究节点的多重性,即年龄,性别属性。我试图为给定的上下文执行给定的代码。在本教程中,他们发现基于性别,同一政党,国家和票据共同点的相似性。首先,他们读取4个CSV文件并将其转换为矩阵格式。当我试图执行时,得到了这个错误

  

predicing_matrices [1,]中的错误< - gender_matrix:         要替换的项目数量不是替换长度的倍数

 getwd()
    library(sna)
    #Load Same-County Network
    county_network=read.csv(file.choose(),header=TRUE)
    county_matrix=as.matrix(county_network)

    #Load Same-Gender Network
    gender_network=read.csv(file.choose(),header=TRUE)
    gender_matrix=as.matrix(gender_network)

    #Load Same-Party Network
    party_network=read.csv(file.choose(),header=TRUE)
    party_matrix=as.matrix(party_network)

    #Load Number-Joint-Cosponsorships Network
    cosp_network=read.csv(file.choose(),header=TRUE)
    cosp_matrix=as.matrix(cosp_network)

    #Join The Predicting Matrices Together
    predicting_matrices <- array (NA, c(3, length(county_network[1,]), length(county_network[1,])))

    predicting_matrices[1,,] <- county_matrix
    Error in predicting_matrices[1, , ] <- county_matrix : 
      number of items to replace is not a multiple of replacement length

    predicting_matrices[2,,] <- gender_matrix
    Error in predicting_matrices[1, , ] <- gender_matrix : 
      number of items to replace is not a multiple of replacement length

    predicting_matrices[3,,] <- party_matrix
    Error in predicting_matrices[1, , ] <- party_matrix : 
      number of items to replace is not a multiple of replacement length


    #Now Run a QAP Regression called model and Show the Results
    model <- netlm(cosp_matrix,predicting_matrices)
    Error in netlm(cosp_matrix, predicting_matrices) : 
      Homogeneous graph orders required in netlm.

0 个答案:

没有答案