transform             package:relations             R Documentation

_T_r_a_n_s_f_o_r_m _i_n_c_i_d_e_n_c_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Carry out transformations between incidence matrices from
     endorelations and other codings.

_U_s_a_g_e:

     transform_incidences(x, from = c("PO","SO","01","-1+1"),
                             to = c("PO","SO","01","-1+1"))

_A_r_g_u_m_e_n_t_s:

       x: An incidence matrix from an endorelation.

from, to: The coding scheme (see details).

_D_e_t_a_i_l_s:

     In the following, we consider an incidence matrix X with cells
     x_{jk} of a relation R with tuples (a_j, b_k).

     For the '"PO"' ("Preference Order") coding, X is a 0/1 matrix, and
      a_j R b_k iff x_{jk} = 1. It follows in particular that if both
     x_{jk} and x_{kj} are 0, the corresponding pair (a_j, b_k) is not
     contained in R, i.e., a_j and b_k are unrelated.

     For the '"SO"' (""Strict Order"") coding, X is a 0/1 matrix with
     possible 'NA' values. As for '"PO"', a_j R b_k iff x_{jk} = 1, but
     at most one of x_{jk} and x_{kj} can be 1. If both are missing
     ('NA'), a_j and b_k are unrelated.

     For the '"01"' coding, X is a matrix with values 0, 1, or 0.5. The
     coding is similar to '"SO"', except that 'NA' is represented by
     0.5.

     For the '"-1+1"' coding, X is a matrix with values -1, 0, or 1.
     The coding is similar to '"SO"', except that 'NA' is represented
     by 0, and x_{jk} = -1 if _not_ a_j R b_k.

_S_e_e _A_l_s_o:

     'relation_incidence'.

_E_x_a_m_p_l_e_s:

     x <- relation(domain = 1:4,
                   graph = set(pair(1,2), pair(4,2), pair(1,3), pair(1,4),
                               pair(3,2), pair(2,1)))
     inc <- relation_incidence(x)
     print(inc)

     transform_incidences(inc, to = "SO")
     transform_incidences(inc, to = "01")
     transform_incidences(inc, to = "-1+1")

     ## transformations should be loss-free:
     inc2 <- transform_incidences(inc, from = "PO", to = "-1+1")
     inc2 <- transform_incidences(inc2, from = "-1+1", to = "SO")
     inc2 <- transform_incidences(inc2, from = "SO", to = "01")
     inc2 <- transform_incidences(inc2, from = "01", to = "PO")
     stopifnot(identical(inc, inc2))

