`link_levels()`

call.`R/cross_levels.R`

`join.Rd`

Helper function handling specification of which variables to join a
cross-classified data on, and what kind of correlation structure needed.
Correlation structures can only be provided if the underlying call is
a `link_levels()`

call.

join(..., rho = 0, sigma = NULL)

... | A series of two or more variable names, unquoted, to join on in order to create cross-classified data. |
---|---|

rho | A fixed (Spearman's rank) correlation coefficient between the
variables being joined on: note that if it is not possible to make a
correlation matrix from this coefficient (e.g. if you are joining on three
or more variables and rho is negative) then the |

sigma | A matrix with dimensions equal to the number of variables you
are joining on, specifying the correlation for the resulting joined data.
Only one of rho and sigma should be provided. Do not provide |

panels <- fabricate( countries = add_level(N = 150, country_fe = runif(N, 1, 10)), years = add_level(N = 25, year_shock = runif(N, 1, 10), nest = FALSE), obs = cross_levels( by = join(countries, years), new_variable = country_fe + year_shock + rnorm(N, 0, 2) ) ) schools_data <- fabricate( primary_schools = add_level(N = 20, ps_quality = runif(N, 1, 10)), secondary_schools = add_level( N = 15, ss_quality = runif(N, 1, 10), nest = FALSE), students = link_levels( N = 1500, by = join(primary_schools, secondary_schools), SAT_score = 800 + 13 * ps_quality + 26 * ss_quality + rnorm(N, 0, 50) ) )