seqblock(object = NULL, id.vars, id.vals, exact.vars = NULL, exact.vals = NULL, exact.restr = NULL, exact.alg = "single", covar.vars = NULL, covar.vals = NULL, covar.restr = NULL, covars.ord = NULL, n.tr = 2, tr.names = NULL, assg.prob = NULL, seed = NULL, seed.dist, assg.prob.stat = NULL, trim = NULL, assg.prob.method = NULL, assg.prob.kfac = NULL, distance = NULL, file.name = NULL, query = FALSE, verbose = TRUE, ...).RData file containing a list output from the seqblock function which contains at least one previously assigned unit.query = FALSE and the object argument is not given, then the id.vars argument is required.id.vars.exact.restr is a vector containing all of the possible values that the first exact blocking variable (see exact.vars above) can take on; the second element is a vector containing all of the possible values for the second exact blocking variable; and so on."single". This algorithm creates a variable with a unique level for every possible combination of the values in all of the exact variables. See Details section below.covar.restr is a vector containing all of the possible values that the first non-exact blocking variable (see covar.vars above) can take on; the second element is a vector containing all of the possible values for the second non-exact blocking variable; and so on.n.tr = 2.cov.rob, used to calculate measures of the variance-covariance matrix robust to outliers.mean, median, and trimmean. If not specified, this defaults to assg.prob.stat = "mean".assg.prob.stat) is set equal to trimmean. Blocks on each tail of the distribution are dropped before the mean is calculated. If not specified, this defaults to trim = 0.1.ktimes, fixed, prop, prop2, and wprop. If not specified, this defaults to assg.prob.method = "ktimes".k, the factor by which the most likely experimental condition will be multiplied relative to the other conditions. If not specified, this defaults to assg.prob.kfac = 2.distance = "mahalanobis".query = FALSE.x returned by the function as part of the bdata list. If not specified, this defaults to verbose = TRUE.bdata) with elementsseqblock function's code is primarily divided into two parts: the first half deals with instances, in which the unit being assigned is the first unit in a given study to receive an assignment; the second half addresses subsequent units that are assigned after at least one first assignment has already been made. If the object argument is left as NULL, the function will run the first half; if the object argument is specified, the second part will be executed. When object = NULL, the researcher has no past file from which to pull variable names and past data; this corresponds to the case when the unit being assigned is the first one. If the researcher does specify object, it implies the user is drawing data from a past file, which means this is not the first unit in the study to be assigned to a treatment.However, the function can be called for subsequent units even when object is not specified. By setting query = TRUE, the console will ask the researcher whether this is the first unit to be assigned in the study. Based on the researcher's response, it will decide which part of the code to run.
If the object and file.name arguments are set to the same value, then seqblock overwrites the specified file with a new file, which now contains both the previously-assigned units and the newly-assigned unit. To create a new file when a new unit is assigned, use a new file.name.
The single algorithm (see exact.alg in the Arguments section above) creates a variable that has a unique level for every possible combination of the exact variables. As an example, say that there were 3 exact blocking variables: party (Democrat, Republican); region (North, South); and education (HS, NHS). The single algorithm creates one level for units with the following values: Democrat-North-HS. It would create another level for Democrat-North-NHS; a third level for Republican-North-HS; and so forth, until every possible combination of these 3 variables has its own level. Thus if there are $k$ exact blocking variables and each exact blocking variable has $q_{i}$ values it can take on, then there are a total of $\prod_{1}^{k} q_{i}$ levels created.
The distance = "mcd" and distance = "mve" options call cov.rob to calculate measures of multivariate spread robust to outliers. The distance = "mcd" option calculates the Minimum Covariance Determinant estimate (Rousseeuw 1985); the distance = "mve" option calculates the Minimum Volume Ellipsoid estimate (Rousseeuw and van Zomeren 1990). When distance = "mcd", the interquartile range on blocking variables should not be zero. The distance = "euclidean" option calculates the Euclidean distance between the new unit and the previously-assigned units. The default distance = "mahalanobis" option calculates the Mahalanobis distance.
Moore, Ryan T. 2012. "Multivariate Continuous Blocking to Improve Political Science Experiments." Political Analysis 20(4):460-479.
Rousseeuw, Peter J. 1985. "Multivariate Estimation with High Breakdown Point". Mathematical Statistics and Applications 8:283-297.
Rousseeuw, Peter J. and Bert C. van Zomeren. 1990. "Unmasking Multivariate Outliers and Leverage Points". Journal of the American Statistical Association 85(411):633-639.
assignment, block## Assign first unit (assume a 25 year old member of the Republican Party) to a treatment group.
## Save the results in file "sdata.RData":
## seqblock(query = FALSE, id.vars = "ID", id.vals = 001, exact.vars = "party",
## exact.vals = "Republican", covar.vars = "age", covar.vals = 25, file.name = "sdata.RData")
## Assign next unit (age 30, Democratic Party):
## seqblock(query = FALSE, object = "sdata.RData", id.vals = 002, exact.vals = "Democrat",
## covar.vars = "age", covar.vals = 30, file.name = "sdata.RData")
Run the code above in your browser using DataLab