A helper function that verifies the linking dataset contains (A) the essential columns exist, and (B) at least one row. It is called by CreatePairLinks.

Typical use of NlsyLinks will not require this function, since a valid paired links are supplied for each supported sample (ie, Links79Pair).

The NlsyLinks uses several types of linking schemas. This function validates the type where each relative subject has their own row.

The following four columns must be present: (1) Subect1Tag, (2) Subect2Tag, (3) R, and (4) MultipleBirth. They must have a numeric mode/datatype.

ValidatePairLinks(linksPair)

Arguments

linksPair

The base::data.frame to validate.

Value

Returns TRUE if the validation passes. Returns an error (and associated descriptive message) if it false.

See also

Examples

dsSingleLinks <- data.frame( ExtendedID = c( 1 , 1, 1 , 2), SubjectTag_S1 = c(101, 101, 102, 201), SubjectTag_S2 = c(102, 103, 103, 202), R = c( .5, .25, .25, .5), RelationshipPath = rep("Gen2Siblings", 4) ) dsSingleOutcomes <- data.frame( SubjectTag = c(101, 102, 103, 201, 202), DV1 = c( 11, 12, 13, 41, 42), DV2 = c( 21, 22, 23, 51, 52) ) dsDouble <- CreatePairLinksDoubleEntered( outcomeDataset = dsSingleOutcomes, linksPairDataset = dsSingleLinks, outcomeNames = c("DV1", "DV2"), validateOutcomeDataset = TRUE ) dsDouble #Show the 8 rows in the double-entered pair links
#> SubjectTag_S1 SubjectTag_S2 ExtendedID R RelationshipPath DV1_S1 DV2_S1 #> 1 101 102 1 0.50 Gen2Siblings 11 21 #> 2 101 103 1 0.25 Gen2Siblings 11 21 #> 3 102 103 1 0.25 Gen2Siblings 12 22 #> 4 201 202 2 0.50 Gen2Siblings 41 51 #> 5 102 101 1 0.50 Gen2Siblings 12 22 #> 6 103 101 1 0.25 Gen2Siblings 13 23 #> 7 103 102 1 0.25 Gen2Siblings 13 23 #> 8 202 201 2 0.50 Gen2Siblings 42 52 #> DV1_S2 DV2_S2 #> 1 12 22 #> 2 13 23 #> 3 13 23 #> 4 42 52 #> 5 11 21 #> 6 11 21 #> 7 12 22 #> 8 41 51
summary(dsDouble) #Summarize the variables
#> SubjectTag_S1 SubjectTag_S2 ExtendedID R #> Min. :101.0 Min. :101.0 Min. :1.00 Min. :0.250 #> 1st Qu.:101.8 1st Qu.:101.8 1st Qu.:1.00 1st Qu.:0.250 #> Median :102.5 Median :102.5 Median :1.00 Median :0.375 #> Mean :126.9 Mean :126.9 Mean :1.25 Mean :0.375 #> 3rd Qu.:127.5 3rd Qu.:127.5 3rd Qu.:1.25 3rd Qu.:0.500 #> Max. :202.0 Max. :202.0 Max. :2.00 Max. :0.500 #> RelationshipPath DV1_S1 DV2_S1 DV1_S2 #> Length:8 Min. :11.00 Min. :21.00 Min. :11.00 #> Class :character 1st Qu.:11.75 1st Qu.:21.75 1st Qu.:11.75 #> Mode :character Median :12.50 Median :22.50 Median :12.50 #> Mean :19.38 Mean :29.38 Mean :19.38 #> 3rd Qu.:20.00 3rd Qu.:30.00 3rd Qu.:20.00 #> Max. :42.00 Max. :52.00 Max. :42.00 #> DV2_S2 #> Min. :21.00 #> 1st Qu.:21.75 #> Median :22.50 #> Mean :29.38 #> 3rd Qu.:30.00 #> Max. :52.00
ValidatePairLinksAreSymmetric(dsDouble) #Should return TRUE.
#> [1] TRUE