Learn R Programming

amen (version 1.0)

simY_ord: Simulate an ordinal relational matrix

Description

Simulates an ordinal relational matrix having a particular marginal distribution

Usage

simY_ord(EZ, rho, Y)

Arguments

EZ
square matrix giving the expected value of the latent Z matrix
rho
scalar giving the within-dyad correlation
Y
ordinal relational data matrix

Value

  • a square matrix

Examples

Run this code
## The function is currently defined as
simY_ord<-
function (EZ, rho,Y)
{

    uY<-sort(unique(c(Y)))
    FY<-table(c(Y)) ; FY<-FY/sum(FY) ; FY<-cumsum(FY)
    ZS <- simZ(EZ, rho)
    diag(ZS) <- NA
    qZ <- quantile(ZS, FY[-length(FY)], na.rm = TRUE)
    YS <- ZS * 0 + max(uY)
    for (w in 1:(length(uY) - 1)) {
        YS[(YS == max(uY)) & ZS <= qZ[w]] <- uY[w]
    }
    YS
}

Run the code above in your browser using DataLab