Description Usage Arguments Details Value Author(s) References Examples

Graphical representation of a correlation matrix, similar to principal component analysis (PCA) but the mapping is on a sphere. The information is close to a 3d PCA, the picture is however easier to interpret since the variables are in fact on a 2d map.

1 |

`datafile` |
name of datafile |

`h` |
rotation of the sphere on a horizontal plane (in degres) |

`v` |
rotation of the sphere on a vertical plane (in degres) |

`f` |
rotation of the sphere on a frontal plane (in degres) |

`cx` |
size of the lettering (0.75 by default, 1 for bigger letters, 0.5 for smaller) |

`nbsphere` |
two by default: front and back |

`back` |
"FALSE" by default: the back sphere is not seen through |

`input` |
"data" by default: raw data are analysed, if not "data": correlation matrix is expected |

`method` |
"approx" by default: the estimation is based on a principal component analysis approximation. If "exact" the "approx" estimation is optimized (may be computationaly consumming). if "rscal" a multidimensional scaling approach is used: distances between points on the sphere are optimized so that they represent at best the original correlations. The scaling that is used leads to angles on the sphere proportional to correlation between variables |

`maxiter` |
maximum number of iterations in the optim process |

`output` |
FALSE by default: if TRUE and method="rscal" numerical results are proposed |

There is an isophormism between a correlation matrix and points on the unit hypersphere of Rn. It can be shown that a 3d spherical representation of a correlation matrix is statistically and cognitively interesting (see reference). The default option method="approx" is based on a principal components approximation (see reference). It is fast and gives rather good results. If method="exact" the representation is sligthly improved in terms of fit (the sphere minimizes the sum of squared distances between the original variables on the hypersphere and their projections on the sphere). The option method="rscal" optimizes the representation of correlations between variables with distances between points (in a least squares sense). For convenience, the scaling of points on the sphere is chosen so that angles between points are linearly related to correlations between variables (this is not the case on the hypersphere were d=[2*(1-r)]^0.5). For method="exact" or method="rscal" computations may be rather lengthy (and not sensible for more than 20-40 variables). The sphere may be rotated to help in visualising most of variables on a same side (front for example). By default, the back of the sphere (right plot) is not seen showing through.

A plot. If method="rscal" and output=TRUE, a list with :

`$stress.before.optim` |
Stress before optimization. The stress is equal to the sum of squares of differences between distances on the 3d sphere and distances on the hypersphere. |

`$stress.after.optim` |
Stress after optimization. |

`$convergence` |
If 0, convergence is OK. If not, maxiter may be increased. |

`$correlations` |
Correlation matrix of variables (Pearson). |

`$residuals` |
Differences between observed correlations (hypersphere) and correlations estimated from points on the 3d sphere. |

`$mean.abs.resid` |
Mean of absolute values of residuals. |

Bruno Falissard

Falissard B, A spherical representation of a correlation matrix, Journal of Classification (1996), 13:2, 267-280.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ```
data(sleep)
sphpca(sleep[,c(2:5,7:11)])
## spherical representation of ecological and constitutional correlates in mammals
sphpca(sleep[,c(2:5,7:11)],method="rscal",output=TRUE)
## idem, but optimizes the representation of correlations between variables with distances between points
corsleep <- as.data.frame(cor(sleep[,c(2:5,7:11)],use="pairwise.complete.obs"))
sphpca(corsleep,input="Cor")
sphpca(corsleep,method="rscal",input="Cor")
## when missing data are numerous, the representation of a pairwise correlation
## matrix may be preferred (even if mathematical properties are not so good...)
sphpca(corsleep,method="rscal",input="Cor",h=180,f=180,nbsphere=1,back=TRUE)
## other option of presentation
##
# library(polycor)
# sleep$Predation <- as.ordered(sleep$Predation)
# sleep$Sleep.exposure <- as.ordered(sleep$Sleep.exposure)
# sleep$Danger <- as.ordered(sleep$Danger)
# corsleeph <- as.data.frame(hetcor(sleep[,c(2:5,7:11)])$correlations)
# sphpca(corsleeph,input="Cor",f=180)
# sphpca(corsleeph,method="rscal",input="Cor",f=180)
## --> Correlations between discrete variables may appear shoking to some statisticians (?)
## --> Representation of polychoric/polyserial correlations could be prefered in this situation
``` |

```
$stress.before.optim
[1] 0.4714109
$stress.after.optim
[1] 0.2167696
$convergence
[1] 0
$correlations
Body.weight Brain.weight Slow.wave.sleep Paradoxical.sleep
Body.weight 1.000 0.956 -0.394 -0.075
Brain.weight 0.956 1.000 -0.387 -0.074
Slow.wave.sleep -0.394 -0.387 1.000 0.518
Paradoxical.sleep -0.075 -0.074 0.518 1.000
Maximum.life.span 0.470 0.629 -0.372 -0.268
Gestation.time 0.714 0.734 -0.606 -0.409
Predation 0.096 -0.015 -0.353 -0.398
Sleep.exposure 0.406 0.323 -0.580 -0.504
Danger 0.259 0.151 -0.535 -0.572
Maximum.life.span Gestation.time Predation Sleep.exposure
Body.weight 0.470 0.714 0.096 0.406
Brain.weight 0.629 0.734 -0.015 0.323
Slow.wave.sleep -0.372 -0.606 -0.353 -0.580
Paradoxical.sleep -0.268 -0.409 -0.398 -0.504
Maximum.life.span 1.000 0.646 -0.170 0.316
Gestation.time 0.646 1.000 0.091 0.573
Predation -0.170 0.091 1.000 0.626
Sleep.exposure 0.316 0.573 0.626 1.000
Danger 0.015 0.306 0.927 0.790
Danger
Body.weight 0.259
Brain.weight 0.151
Slow.wave.sleep -0.535
Paradoxical.sleep -0.572
Maximum.life.span 0.015
Gestation.time 0.306
Predation 0.927
Sleep.exposure 0.790
Danger 1.000
$residuals
Body.weight Brain.weight Slow.wave.sleep Paradoxical.sleep
Body.weight 0.000 0.058 -0.257 -0.127
Brain.weight 0.058 0.000 -0.255 -0.132
Slow.wave.sleep -0.257 -0.255 0.000 -0.150
Paradoxical.sleep -0.127 -0.132 -0.150 0.000
Maximum.life.span -0.051 0.025 -0.210 -0.221
Gestation.time 0.002 0.004 -0.377 -0.306
Predation -0.068 -0.117 -0.236 -0.255
Sleep.exposure -0.043 -0.065 -0.350 -0.330
Danger -0.003 -0.051 -0.349 -0.388
Maximum.life.span Gestation.time Predation Sleep.exposure
Body.weight -0.051 0.002 -0.068 -0.043
Brain.weight 0.025 0.004 -0.117 -0.065
Slow.wave.sleep -0.210 -0.377 -0.236 -0.350
Paradoxical.sleep -0.221 -0.306 -0.255 -0.330
Maximum.life.span 0.000 -0.024 -0.167 0.051
Gestation.time -0.024 0.000 -0.120 0.032
Predation -0.167 -0.120 0.000 0.003
Sleep.exposure 0.051 0.032 0.003 0.000
Danger -0.094 -0.037 0.094 0.016
Danger
Body.weight -0.003
Brain.weight -0.051
Slow.wave.sleep -0.349
Paradoxical.sleep -0.388
Maximum.life.span -0.094
Gestation.time -0.037
Predation 0.094
Sleep.exposure 0.016
Danger 0.000
$mean.abs.resid
[1] 0.1407018
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.