Skip to contents

A line-for-line port of the BLACKBOXT Fortran routine of the basicspace package. The stimuli-by-respondents matrix is decomposed as X = P W' + J c' + E one dimension at a time by alternating least squares (starting values from sign-corrected row means, column signs from the pairwise-complete correlation matrix), refined with all dimensions jointly, and the fitted P t(W) is re-expressed by its singular value decomposition. Stimulus coordinates are the unit right singular vectors; respondent weights are U sqrt(s) with intercepts c. In two dimensions the solution is rotated so its first axis matches the one-dimensional solution, as in the Fortran. Respondents with fewer than dims + 2 answers are dropped (NULL rows); stimuli with fewer than 8 answers are excluded from the starting values. Needs more scaled respondents than stimuli. Singular vectors are signed so that each one's largest entry is positive (LAPACK's signs are arbitrary), so columns can differ in sign from basicspace, which also rounds to three decimals. Identical to the Python arm morie.fn.blackboxt.

Usage

BlackboxTranspose(data, missing = NULL, dims = 1)

Arguments

data

Respondents (rows) by stimuli (columns) numeric matrix; NA or any value in missing is missing.

missing

Optional vector of missing-value codes.

dims

Number of dimensions (solutions for 1 to dims are returned).

Value

A list with stimuli (per dimension, rows n, coord_1..coord_d, R2), individuals (per dimension, rows c, w_1..w_d, R2 or NULL), fits (per dimension: SSE, SSE_explained, percent, cumulative_percent, R2, SE, singular), n_row (stimuli), n_col (scaled respondents), n_data, n_miss, ss_mean and dims.

References

Poole, K. T. (1998). Recovering a basic space from a set of issue scales. American Journal of Political Science 42, 954-993.

Poole, K., Lewis, J., Rosenthal, H., Lo, J. and Carroll, R. (2016). Recovering a basic space from issue scales in R. Journal of Statistical Software 69(7), 1-21.

Examples

X <- outer(1:12, 1:4, function(i, j) (i * 7 + j * 3) %% 10 + ifelse(i %% 2 == 1, -j, j) * 0.3)
r <- BlackboxTranspose(X, dims = 1)
r$fits[[1]]$R2
#> [1] 0.5530949