Collapses each community of items into a single super-node. score methods
build a composite column per community from the raw data and return a reduced
data.frame (re-estimate the macro network with psychnet() on it). assoc
methods summarise each community pair's multivariate association directly and
return the macro network as a psychnet.
Usage
net_aggregate(
data,
communities,
method = "mean",
estimator = "glasso",
scale = TRUE,
labels = NULL,
...
)Arguments
- data
A numeric data frame or matrix (rows = observations, columns = items).
- communities
Community membership, one entry per item (column): a vector aligned to the columns, or a named vector / list keyed by item label.
- method
Aggregation method. Score (return reduced data):
"mean"(default),"median","sum","pca"(first principal component),"factor"(1-factor score, falls back to PCA for communities of < 3 items),"loadings"(within-community connectivity-weighted mean). Association (return macro network):"average"(mean signed edge weight between communities),"rv"(Escoufier RV coefficient),"canonical"(first canonical correlation).- estimator
Estimator used for the node-level network that
"loadings"and"average"need (seepsychnet()). Default"glasso".- scale
Standardise each item before forming score composites. Default
TRUE.- labels
Optional item labels (used when
datahas no column names).- ...
Passed to the estimator.
Value
For a score method, a data.frame with one column per community
(one row per observation). For an association method, a psychnet macro
network among communities.
Examples
net_aggregate(SRL_Claude, communities = c(1, 1, 2, 2, 2)) # reduced data
#> 1 2
#> 1 0.09525105 -0.411140886
#> 2 1.20524782 0.118325681
#> 3 1.20524782 0.592755805
#> 4 0.56974380 0.625947243
#> 5 -0.40948737 -0.140974646
#> 6 -1.23446838 0.123155346
#> 7 -1.37697626 -0.493792185
#> 8 -0.32729145 -0.583247505
#> 9 -0.83701103 -0.808762696
#> 10 0.34503999 0.340372678
#> 11 0.20591267 -0.205536387
#> 12 0.80280932 0.319234549
#> 13 0.42723591 -0.426355947
#> 14 -1.17913757 0.159661758
#> 15 0.26124348 -0.238881047
#> 16 0.42723591 0.058153129
#> 17 1.22535181 0.892951732
#> 18 1.11469019 0.774540941
#> 19 -0.67439915 -0.435400725
#> 20 1.17002100 0.567115307
#> 21 0.71563224 0.099795648
#> 22 1.00402857 0.729736671
#> 23 -0.80854532 -0.471907136
#> 24 1.15827873 0.814209104
#> 25 0.59322835 0.696392011
#> 26 0.84639785 0.226311034
#> 27 -0.63917233 -0.680119732
#> 28 0.27298575 -0.037185218
#> 29 1.18176328 0.848147461
#> 30 0.40375136 0.025595431
#> 31 -0.55199526 -0.443698585
#> 32 0.27298575 -0.231176885
#> 33 0.17068585 -0.199172842
#> 34 0.09525105 -0.419438746
#> 35 -1.62178405 -0.236025738
#> 36 0.53789753 0.117925248
#> 37 0.77096305 0.732898422
#> 38 0.78270533 0.140651206
#> 39 1.08284393 0.108053465
#> 40 0.37190510 -0.152434257
#> 41 -1.26631464 -0.371032248
#> 42 1.26057864 0.887221926
#> 43 1.04761711 0.720251416
#> 44 -0.74147224 -0.393164508
#> 45 -0.24349494 -0.168396236
#> 46 -0.34739544 -0.592885981
#> 47 0.36016283 -0.244610852
#> 48 -1.85484957 -0.477983427
#> 49 -0.90408411 -0.356658097
#> 50 0.12709731 -0.392417589
#> 51 -0.66603744 0.232674580
#> 52 -0.24349494 0.169493497
#> 53 0.38364737 -0.095977111
#> 54 0.22601666 -0.229796226
#> 55 0.26124348 -0.452783406
#> 56 -0.63081061 -0.283645275
#> 57 0.01643569 -0.204902647
#> 58 -1.37697626 -0.539190153
#> 59 0.69214769 0.245821293
#> 60 -0.98628003 -0.814339280
#> 61 1.40308652 0.444162106
#> 62 0.64855916 0.194540297
#> 63 -0.22837210 -0.444485546
#> 64 -1.56645324 -0.073404374
#> 65 0.34842055 0.030137841
#> 66 0.73911679 0.217612741
#> 67 0.43897819 -0.269657652
#> 68 -1.40046081 -0.289721566
#> 69 -0.85213386 -0.393164508
#> 70 1.01577084 0.404493943
#> 71 -1.42056480 -0.610421883
#> 72 0.36016283 0.071987530
#> 73 -1.62178405 -0.664711408
#> 74 0.94869776 0.289244904
#> 75 -0.02217169 0.305246926
#> 76 -0.57547980 -0.521253817
#> 77 0.97218231 0.766243082
#> 78 -0.91920694 -0.153968137
#> 79 -0.12945276 -0.387434703
#> 80 1.28068262 0.771972887
#> 81 0.78270533 0.221961888
#> 82 -0.98628003 -0.460447525
#> 83 -0.25185665 -0.188940668
#> 84 0.54963981 0.058153129
#> 85 -0.12109104 0.221214969
#> 86 1.19350555 0.654155794
#> 87 1.33601344 1.337792645
#> 88 -1.28641863 0.050142524
#> 89 1.56907895 1.049843290
#> 90 0.15058186 -0.251087577
#> 91 -1.64188804 -0.477983427
#> 92 -0.12607220 -0.384119730
#> 93 0.56138208 0.061908578
#> 94 -1.51948415 -0.474227978
#> 95 1.29242490 0.693230260
#> 96 -1.68885714 -0.167955760
#> 97 0.40037081 0.974262414
#> 98 -0.57547980 -0.393164508
#> 99 -1.81962275 -0.808762696
#> 100 -1.06509539 -0.312047090
#> 101 0.06002422 -0.329236507
#> 102 -1.02986856 -0.280830009
#> 103 0.01643569 -0.413708940
#> 104 0.63681688 0.153298212
#> 105 1.14991701 0.634992021
#> 106 -0.97453775 -0.594860337
#> 107 0.89336695 0.042744805
#> 108 -0.52014899 -0.597428391
#> 109 0.54625925 -0.003246861
#> 110 -0.88736068 -0.047763877
#> 111 0.37190510 -0.382932335
#> 112 0.88162467 0.617649383
#> 113 1.04761711 0.976236770
#> 114 0.48256672 -0.200400279
#> 115 -0.24847609 -0.532713428
#> 116 1.37124026 0.849528120
#> 117 0.49430900 -0.022370591
#> 118 0.26124348 -0.256223685
#> 119 -1.14053019 -0.533460347
#> 120 1.07110165 0.777702693
#> 121 -0.74645339 -0.189840808
#> 122 0.27298575 -0.357291837
#> 123 1.17002100 0.648425989
#> 124 0.26124348 -0.233744939
#> 125 -1.47589561 -0.775418036
#> 126 -1.72070340 -0.682054046
#> 127 1.17002100 0.777702693
#> 128 0.15058186 -0.236906690
#> 129 -0.79680305 0.317147013
#> 130 -1.49938016 -0.077753521
#> 131 0.96044003 0.152264038
#> 132 -0.09760649 -0.332398259
#> 133 1.20524782 0.208527920
#> 134 0.56138208 -0.027699963
#> 135 -1.21934555 -0.255783209
#> 136 -1.12042620 -0.761830847
#> 137 0.27298575 -0.074285327
#> 138 -1.33338773 -0.398647102
#> 139 1.13817474 0.561385502
#> 140 1.34775571 0.811641050
#> 141 0.48256672 -0.278549209
#> 142 -0.89910295 0.151363898
#> 143 1.34775571 0.192525899
#> 144 -0.28708347 -0.014072732
#> 145 -0.27534120 -0.377989491
#> 146 -1.49938016 -0.016794007
#> 147 -1.12380676 0.025248946
#> 148 0.45072046 -0.269063955
#> 149 -1.02986856 -0.578264618
#> 150 -0.56711809 0.221214969
#> 151 0.61671289 -0.226827738
#> 152 -1.34174944 -0.512362260
#> 153 -0.20488756 -0.213200507
#> 154 -1.17237645 -0.934877649
#> 155 0.39538965 -0.118495900
#> 156 -0.56373753 -0.276728074
#> 157 -1.78777649 -0.471466660
#> 158 1.22535181 0.766243082
#> 159 0.38026682 -0.295104886
#> 160 0.43897819 -0.231176885
#> 161 1.22535181 1.206734848
#> 162 0.12371675 -0.241409058
#> 163 0.37190510 -0.270251350
#> 164 0.69214769 0.668183460
#> 165 0.74747850 0.482049176
#> 166 0.53789753 -0.192102420
#> 167 -1.07683766 0.070053216
#> 168 1.22535181 0.880304726
#> 169 0.71563224 0.425038375
#> 170 0.41549364 0.047287215
#> 171 0.42723591 0.046693518
#> 172 -0.35415656 0.100829822
#> 173 1.20524782 0.393628030
#> 174 1.43493278 1.267347877
#> 175 0.78270533 -0.111578699
#> 176 0.32831656 -0.079421435
#> 177 0.56138208 0.171427812
#> 178 0.49430900 -0.101306483
#> 179 -1.37697626 -0.620500835
#> 180 1.20524782 0.438432301
#> 181 0.60497062 0.027529745
#> 182 0.37190510 -0.152434257
#> 183 -0.45307591 -0.401061934
#> 184 1.13817474 0.318834115
#> 185 -1.17575701 -0.604885341
#> 186 -0.46143762 -0.606319948
#> 187 0.58148607 0.472811134
#> 188 -0.25185665 -0.457132552
#> 189 -0.46481818 -0.283645275
#> 190 -0.50840672 -0.363174864
#> 191 -2.21031899 -0.929147843
#> 192 -0.82028759 -0.718407236
#> 193 1.15827873 0.935187949
#> 194 -1.70896113 -0.727452014
#> 195 -0.03889512 0.632711222
#> 196 0.06002422 -0.111385435
#> 197 -1.55471097 -0.353842831
#> 198 1.20524782 0.609351524
#> 199 0.41549364 0.349264235
#> 200 -0.91920694 -0.414455859
#> 201 0.20253211 0.409476830
#> 202 1.13817474 0.576793826
#> 203 -0.33405257 0.324811133
#> 204 0.78270533 0.349610721
#> 205 -1.78777649 -0.479764520
#> 206 0.20591267 -0.191508722
#> 207 -0.06237967 -0.538443234
#> 208 -1.00976458 -0.036151044
#> 209 -1.56645324 -0.152147002
#> 210 -2.66808831 -0.934877649
#> 211 -0.57547980 -0.110944959
#> 212 0.54963981 0.388531964
#> 213 1.72332911 1.662441675
#> 214 0.48256672 -0.152434257
#> 215 -0.29882575 0.218646915
#> 216 -1.04161084 -0.211572636
#> 217 0.05664367 0.236776514
#> 218 1.00402857 0.887221926
#> 219 1.35949798 1.047275236
#> 220 -0.88736068 0.017738047
#> 221 0.66030143 -0.076259683
#> 222 1.02413256 0.753596076
#> 223 -0.27196064 -0.477043244
#> 224 0.38364737 -0.267683296
#> 225 -0.68614142 -0.500308952
#> 226 -0.39774510 -0.204902647
#> 227 -0.94269149 -0.596641430
#> 228 0.51441299 0.742383677
#> 229 -0.39774510 -0.358038756
#> 230 -0.75321451 -0.056061736
#> 231 0.56138208 -0.094982980
#> 232 -0.86387613 -0.749183841
#> 233 0.31657429 -0.267683296
#> 234 1.23709409 0.766243082
#> 235 -1.03324912 -0.320498171
#> 236 0.73911679 0.446730160
#> 237 -0.85213386 -0.575696564
#> 238 0.48256672 -0.130108732
#> 239 -1.67711487 0.050142524
#> 240 -1.77603421 -0.781147842
#> 241 1.20524782 0.887221926
#> 242 0.44733990 0.262817446
#> 243 -0.19652584 -0.314461923
#> 244 -0.97453775 -0.777392393
#> 245 0.80280932 0.492321392
#> 246 -0.90746467 -0.303155533
#> 247 0.31657429 -0.309919513
#> 248 0.25448236 0.602087838
#> 249 0.37190510 -0.188940668
#> 250 1.42657107 1.097215615
#> 251 -1.82798447 -0.634088024
#> 252 0.15058186 -0.236312993
#> 253 -0.53687242 -0.575696564
#> 254 1.07110165 0.848147461
#> 255 -0.96617604 -0.255189511
#> 256 -1.36523399 -0.432585459
#> 257 1.40308652 0.693230260
#> 258 -1.21934555 -0.721722209
#> 259 1.29242490 0.693230260
#> 260 -1.41718424 -0.575696564
#> 261 0.38364737 -0.188940668
#> 262 -1.29816090 -0.464396238
#> 263 0.96880175 -0.022370591
#> 264 1.31252889 0.975049375
#> 265 -0.86725669 -0.036897963
#> 266 0.30981317 1.148783865
#> 267 -0.94269149 -0.625043245
#> 268 1.23709409 0.929458143
#> 269 -0.28708347 -0.291943135
#> 270 0.77096305 0.053017021
#> 271 -1.23446838 -0.171310775
#> 272 1.01577084 0.190744806
#> 273 0.71563224 0.113229616
#> 274 0.39200909 0.226311034
#> 275 -0.91920694 -0.378543146
#> 276 0.84639785 0.455814981
#> 277 -0.69948430 -0.604498813
#> 278 0.50605127 -0.022563855
#> 279 0.61333233 0.581336236
#> 280 0.37190510 -0.209445058
#> 281 -0.06237967 -0.574949645
#> 282 0.31657429 -0.194670474
#> 283 -1.16739529 -0.053493682
#> 284 0.53789753 0.094659540
#> 285 1.23709409 0.766243082
#> 286 0.32831656 -0.354130086
#> 287 -0.75321451 -0.463015579
#> 288 -0.32231030 -0.296292281
#> 289 0.09187049 0.026782826
#> 290 0.67204370 0.067638384
#> 291 -1.65363032 -0.612202975
#> 292 -1.48763789 -0.197544970
#> 293 0.90510922 0.511445123
#> 294 -0.93432978 0.153931952
#> 295 0.09187049 -0.354130086
#> 296 0.78270533 0.255900245
#> 297 0.41549364 0.372529943
#> 298 0.54963981 0.053017021
#> 299 -0.01879113 0.494542961
#> 300 1.23709409 0.278972688
net_aggregate(SRL_Claude, communities = c(1, 1, 2, 2, 2), method = "rv") # macro net
#> <psychnet> aggregate_rv network
#> nodes: 2 edges: 1 (undirected)