library(NlsyLinks) #Load the package into the current R session.
ds <- Links79PairExpanded #Load the dataset from the NlsyLinks package.
oName_1 <- "MathStandardized_1" #Stands for Manifest1
oName_2 <- "MathStandardized_2" #Stands for Manifest2
dsGroupSummary <- RGroupSummary(ds, oName_1, oName_2)
dsGroupSummary
#Should return:
# R Included PairCount M1Variance M2Variance M1M2Covariance Correlation Determinant PosDefinite
#1 0.250 TRUE 2719 169.1291 207.0233 40.66048 0.2172970 33360.38 TRUE
#2 0.375 TRUE 43 187.7209 220.9302 28.66334 0.1407482 40651.64 TRUE
#3 0.500 TRUE 5508 230.9663 233.3492 107.59822 0.4634764 42318.42 TRUE
#4 0.750 FALSE 2 220.5000 18.0000 63.00000 1.0000000 0.00 FALSE
#5 1.000 TRUE 22 319.1948 343.1169 277.58874 0.8387893 32465.62 TRUE
#To get summary stats for the whole sample, create one large inclusive group.
ds$Dummy <- 1
(dsSampleSummary <- RGroupSummary(ds, oName_1, oName_2, rName="Dummy"))
#Should return:
# Dummy Included PairCount M1Variance M2Variance M1M2Covariance Correlation Determinant PosDefinite
#1 1 TRUE 8392 216.466 229.2988 90.90266 0.4080195 41372.1 TRUE
Run the code above in your browser using DataLab