Toolbox function that sets anchors to bridge two datasets.

setanchors(
  d1,
  d2,
  anchors.method = "subsample",
  anchors.subsample.method = "random",
  anchors.subsample.pr = 0.1,
  anchors.subsample.wgt.d1 = NULL,
  anchors.subsample.wgt.d2 = NULL,
  anchors.selectrows.d1 = 1:100,
  anchors.selectrows.d2 = 1:100,
  anchors.selectrows.data = NULL,
  anchors.newdata = NULL
)

Arguments

d1

Matrix or data.frame of 'reference' responses. (i.e., In mapping methods, ideal points based on d2 will be transformed and mapped to ideal point space based on d1). Rows are resepondents and columns are questions/issues.

d2

Matrix or data.frame of responses to be transformed.

anchors.method

Method to select anchors to bridge ideal points. Following values are currently available. Ignored if bridge.method is "joint" or "modelmap".

  • "subsample" (default): Sample subset of d1 and d2 and use them as anchors. Sampled anchors from another dataset are added to the target dataset when computing ideal points on each dataset. See anchors.subsample.pr and anchors.subsample.method for sampling options.

  • "selectrows": Use this option if specific anchors are already included in both d1 and d2. Row numbers for anchors must be set in anchors.selectrows.d1 and anchors.selectrows.d2, respectively (Two vectors must have the same length and each element must corresponds to the same anchor respondent). This is the only option for anchors selection if input.type=="idealpoints".

  • "newdata" Use new dataset that only contains anchors. The data.frame assigned in anchors.newdata are appended to both d1 and d2.

Note that "subsample" and "newdata" requires d1 and d2 to have identical columns. This is not required for "selectrows".

anchors.subsample.method

Method to sample anchors. Following values are currently available:

  • "random" (default): randomly sample subset of both datasets and use them as anchors. The sample size is determined by anchors.subsample.pr.

  • "random.d1": randomly sample subset of d1 and use them as anchors. The sample size is determined by anchors.subsample.pr.

  • "random.d2": randomly sample subset of d2 and use them as anchors. The sample size is determined by anchors.subsample.pr.

  • "selectrows": Use this option if specific anchors are already known ( but not shared between datasets). Row numbers for anchors must be set in anchors.selectrows.d1 and anchors.selectrows.d2, respectively (Two vectors does not have to have the same length).

anchors.subsample.pr

Numeric vector of length 1 or 2. Used when anchors.method=="subsample". Proportion of dataset (i.e., d1 and d2) to be sampled as anchor. When length is 1, the propotion is determined by the dataset of smaller size if anchors.subsample.method=="random", specific dataset's size if anchors.subsample.method is "random.d1" or "random.d2". When length is 2 and anchors.subsample.method=="random", the first element determines the proportion in d1, the second element determines the proportion in d2.

anchors.subsample.wgt.d1

Optional weights passed to prob option of sample function used in random sampling of anchors from d1 when anchors.subsample.method is "random" or "random.d1". If not NULL, it must be a vector of length equals to nrow(d1).

anchors.subsample.wgt.d2

Optional weights passed to prob option of sample function used in random sampling of anchors from d2 when anchors.subsample.method is "random" or "random.d2". If not NULL, it must be a vector of length equals to nrow(d1).

anchors.selectrows.d1

Must be the vector of positive integers. Specify the row numbers of anchors in d1. If anchors.method=="selectrows", must be the same length and with perfect correspondence with anchors.selectrows.d2. If anchors.method=="subsample" and anchors.subsample.method=="selectrows", the above condition is not required.

anchors.selectrows.d2

Must be the vector of positive integers. Specify the row numbers of anchors in d2.

anchors.selectrows.data

Required if anchors.method=="selectrows". Specify the dataset where anchors are originally found. Must be the same length as anchors.selectrows.d1. Allowed values are 1 (=d1), 2 (=d2) and 3 (=new data).

anchors.newdata

Matrix or data.frame of anchors. Must have identical columns as d1 and d2. Used if anchors.method=="newdata".

Value

A list with the following elements:

  • bridge.data: data.frame to store the ideal point estimates in the next method.

  • d.ip1: d1 with anchors.

  • d.ip2: d2 with anchors.

  • anchorrows.ip1: Anchor locations in d.ip1.

  • anchorrows.ip2: Anchor locations in d.ip2.

  • anchorrows.ip1.data: Original dataset for anchors identified in anchorrows.ip1.

  • anchorrows.ip2.data: Original dataset for anchors identified in anchorrows.ip2.

See also