Title: | Optimal Scaling |
---|---|
Description: | Optimal scaling of a data vector, relative to a set of targets, is obtained through a least-squares transformation subject to appropriate measurement constraints. The targets are usually predicted values from a statistical model. If the data are nominal level, then the transformation must be identity-preserving. If the data are ordinal level, then the transformation must be monotonic. If the data are discrete, then tied data values must remain tied in the optimal transformation. If the data are continuous, then tied data values can be untied in the optimal transformation. |
Authors: | Dave Armstrong [aut, cre], William Jacoby [aut] |
Maintainer: | Dave Armstrong <[email protected]> |
License: | GPL-2 |
Version: | 1.2.3 |
Built: | 2024-12-13 06:29:56 UTC |
Source: | CRAN |
This package provides tools to perform an optimal scaling analysis on a data vector. The main result of the optimal scaling is a vector of scores which are a least-squares approximation to a vector of quantitative values, subject to measurement constraints based upon a vector of qualitative data values. See Young (1981) for details.
Package: | optiscale |
Type: | Package |
Version: | 1.2.2 |
Date: | 2021-02-02 |
License: | GPL-2 |
LazyLoad: | yes |
The function that performs the optimal scaling is opscale()
.
It produces an object of class "opscale".
Generic methods are defined for print
, summary
, and
plot
(graphing optimally-scaled values versus
original data values).
William G. Jacoby
Maintainer: William G. Jacoby <[email protected]>
Young, Forrest W. (1981) “Quantitative Analysis of Qualitative Data.” Psychometrika 46: 357-388.
opscale,plot.opscale, print.opscale,
summary.opscale
### x1 is vector of qualitative data ### x2 is vector of quantitative values x1 <- c(1,1,1,1,2,2,2,3,3,3,3,3,3) x2 <- c(3,2,2,2,1,2,3,4,5,2,6,6,4) ### Optimal scaling, specifying that x1 ### is ordinal-discrete op.scaled <- opscale(x.qual=x1, x.quant=x2, level=2, process=1) print(op.scaled) summary(op.scaled)
### x1 is vector of qualitative data ### x2 is vector of quantitative values x1 <- c(1,1,1,1,2,2,2,3,3,3,3,3,3) x2 <- c(3,2,2,2,1,2,3,4,5,2,6,6,4) ### Optimal scaling, specifying that x1 ### is ordinal-discrete op.scaled <- opscale(x.qual=x1, x.quant=x2, level=2, process=1) print(op.scaled) summary(op.scaled)
This data set contains several variables from the Center for Political Studies 1992 National Election Study. Observations with missing values on any of the variables have been deleted.
data(elec92)
data(elec92)
A data frame with 1653 observations on the following 7 variables.
caseid
NES case identification number
bush
Respondents feeling thermometer rating of George H. W. Bush
ideol
Respondents ideological self-placement, seven-point scale ranging from 1=extremely liberal to 7=extremely conservative
econ4yr
Respondents judgment whether national economy has gotten better or worse over preceding four years, five-point scale ranging from 1=much better to 5=much worse
party
Respondents party identification, seven-point scale ranging from 0=strong Democrat to 6=strong Republican
choice
Difference in respondents feeling thermometer ratings of Bush and Clinton
clinton
Respondent”s feeling thermometer rating of Bill Clinton
The full data set from which these observations and variables were extracted is available on the Study Page for the American National Election Studies 1992 Time Series Study, at https://electionstudies.org/data-center/1992-time-series-study/.
Jacoby, William G. (1999) “Levels of Measurement and Political Research: An Optimistic View.” American Journal of Political Science 43: 271-301.
library(optiscale) data(elec92) summary(lm(choice ~ party + ideol + econ4yr, data = elec92))
library(optiscale) data(elec92) summary(lm(choice ~ party + ideol + econ4yr, data = elec92))
Plot, print, shepard, stress, and summary methods for objects of class opscale
## S3 method for class 'opscale' plot(x, ...) ## S3 method for class 'opscale' print(x, ...) ## S3 method for class 'opscale' summary(object, ...)
## S3 method for class 'opscale' plot(x, ...) ## S3 method for class 'opscale' print(x, ...) ## S3 method for class 'opscale' summary(object, ...)
object |
Object of class |
x |
Object of class |
... |
Ignored |
Method print
returns a listing of the data.
summary
describes the optimal scale transformation.
plot
calls os.plot
and returns an object of class trellis
that
graphs optimally-scaled values against the original (qualitative)
data values.
### x1 is vector of qualitative data ### x2 is vector of quantitative values x1 <- c(1,1,1,1,2,2,2,3,3,3,3,3,3) x2 <- c(3,2,2,2,1,2,3,4,5,2,6,6,4) ### Optimal scaling, specifying that x1 ### is ordinal-discrete op.scaled <- opscale(x.qual=x1, x.quant=x2, level=2, process=1) print(op.scaled) summary(op.scaled) plot(op.scaled)
### x1 is vector of qualitative data ### x2 is vector of quantitative values x1 <- c(1,1,1,1,2,2,2,3,3,3,3,3,3) x2 <- c(3,2,2,2,1,2,3,4,5,2,6,6,4) ### Optimal scaling, specifying that x1 ### is ordinal-discrete op.scaled <- opscale(x.qual=x1, x.quant=x2, level=2, process=1) print(op.scaled) summary(op.scaled) plot(op.scaled)
This function produces an object of class "opscale", containing a vector that is a least-squares approximation to a vector of quantitative values, subject to measurement constraints based upon a vector of qualitative data values.
opscale(x.qual, x.quant = seq(1:length(x.qual)), level = 1, process = 1, na.impute = FALSE, na.assign = TRUE, rescale = TRUE)
opscale(x.qual, x.quant = seq(1:length(x.qual)), level = 1, process = 1, na.impute = FALSE, na.assign = TRUE, rescale = TRUE)
x.qual |
A vector of data values, assumed to be qualitative. |
x.quant |
A vector of quantitative values. |
level |
Measurement level of |
process |
Measurement process of |
na.impute |
If |
na.assign |
If |
rescale |
If |
The opscale()
function operationalizes a measurement theory
proposed by Young (1981) in order to facilitate an analysis strategy
called “Alternating Least Squares, Optimal Scaling”.
The optimal scaling transformation produces a vector (say, OS
)
that is a least-squares approximation to x.quant
, subject to
measurement constraints based upon x.qual
.
If x.qual
is nominal level, then the values in OS
are
the conditional means of x.quant
, within distinct categories
of x.qual
. If x.qual
is ordinal level, then the values in
OS
are the conditional means of x.quant
, adjusted to be
weakly monotonic to the values in x.qual
, using Kruskals (1964b)
monotonic transformation.
If x.qual
is discrete, then all data objects sharing a common value
in x.qual
must be assigned the same value in OS
.
If x.qual
is continuous, then data objects sharing a common value
in x.qual
can fall within a closed interval of values in OS
.
The continuous-discrete measurement process distinction corresponds to
Kruskals (1964a) primary and secondary approaches to ties.
The opscale()
function returns an object of class "opscale"
containing a list with the following components:
qual |
The qualitative data vector, |
quant |
The vector of quantitative values, |
os |
The vector of optimally scaled values |
varname |
The name of the qualitative data vector, |
measlev |
The measurement level of the qualitative data vector specified
in the |
measproc |
The measurement process of the qualitative data vector specified
in the |
rescale |
Value of the |
os.raw.mean |
Mean of optimally scaled values before rescaling |
os.raw.sd |
Standard deviation of optimally scaled values before rescaling |
Kruskal, Joseph B. (1964a) “Multidimensional Scaling by Optimizing Goodness of Fit to a Nonmetric Hypothesis.” Psychometrika 29: 1-27.
Kruskal, Joseph B. (1964b) “Nonmetric Multidimensional Scaling: A Numerical Method.” Psychometrika 29: 115-129.
Young, Forrest W. (1981) “Quantitative Analysis of Qualitative Data.” Psychometrika 46: 357-388.
plot.opscale, print.opscale,
summary.opscale
### x1 is vector of qualitative data ### x2 is vector of quantitative values x1 <- c(1,1,1,1,2,2,2,3,3,3,3,3,3) x2 <- c(3,2,2,2,1,2,3,4,5,2,6,6,4) ### Optimal scaling, specifying that x1 ### is ordinal-discrete op.scaled <- opscale(x.qual=x1, x.quant=x2, level=2, process=1) print(op.scaled) summary(op.scaled)
### x1 is vector of qualitative data ### x2 is vector of quantitative values x1 <- c(1,1,1,1,2,2,2,3,3,3,3,3,3) x2 <- c(3,2,2,2,1,2,3,4,5,2,6,6,4) ### Optimal scaling, specifying that x1 ### is ordinal-discrete op.scaled <- opscale(x.qual=x1, x.quant=x2, level=2, process=1) print(op.scaled) summary(op.scaled)
Line and point plot showing optimally-scaled values on the vertical axis, original data values (assumed to be qualitative) on the horizontal axis.
os.plot(x.qual, os.data, main.title = "Plot of optimal transformation")
os.plot(x.qual, os.data, main.title = "Plot of optimal transformation")
x.qual |
Vector of data values, assumed to be qualitative. |
os.data |
Vector of optimally-scaled data values. |
main.title |
Main title for plot. |
Object of class trellis
.
### x1 is vector of qualitative data ### x2 is vector of quantitative values x1 <- c(1,1,1,1,2,2,2,3,3,3,3,3,3) x2 <- c(3,2,2,2,1,2,3,4,5,2,6,6,4) ### Optimal scaling, specifying that x1 ### is ordinal-discrete op.scaled <- opscale(x.qual=x1, x.quant=x2, level=2, process=1) ### Plot of optimal scaling transformation os.plot(op.scaled$qual, op.scaled$os)
### x1 is vector of qualitative data ### x2 is vector of quantitative values x1 <- c(1,1,1,1,2,2,2,3,3,3,3,3,3) x2 <- c(3,2,2,2,1,2,3,4,5,2,6,6,4) ### Optimal scaling, specifying that x1 ### is ordinal-discrete op.scaled <- opscale(x.qual=x1, x.quant=x2, level=2, process=1) ### Plot of optimal scaling transformation os.plot(op.scaled$qual, op.scaled$os)
Graph showing data (assumed quantitative) on vertical axis, optimally-scaled data on horizontal axis.
shepard(x, ...) shep.plot(x.quant, os.data, main.title = "Shepard Diagram")
shepard(x, ...) shep.plot(x.quant, os.data, main.title = "Shepard Diagram")
x |
An object of class |
x.quant |
Data vector, assumed to be quantitative. |
os.data |
Optimally-scaled data. |
main.title |
Main title for graph. |
... |
Ignored |
shepard()
and shep.plot()
both
produce an object of class trellis
If using shep.plot()
,
the Shepard diagram should be created using "raw" optimally scaled values.
That is, the OS values should NOT be rescaled to the mean and standard
deviation of the original qualitative data.
### x1 is vector of qualitative data ### x2 is vector of quantitative values x1 <- c(1,1,1,1,2,2,2,3,3,3,3,3,3) x2 <- c(3,2,2,2,1,2,3,4,5,2,6,6,4) ### Optimal scaling, specifying that x1 ### is ordinal-discrete, optimally scaled ### values are not rescaled op.scaled <- opscale(x.qual=x1, x.quant=x2, level=2, process=1, rescale=FALSE) ### Create Shepard diagram shepard(op.scaled) ### Same results are produced by: shep.plot(op.scaled$quant, op.scaled$os)
### x1 is vector of qualitative data ### x2 is vector of quantitative values x1 <- c(1,1,1,1,2,2,2,3,3,3,3,3,3) x2 <- c(3,2,2,2,1,2,3,4,5,2,6,6,4) ### Optimal scaling, specifying that x1 ### is ordinal-discrete, optimally scaled ### values are not rescaled op.scaled <- opscale(x.qual=x1, x.quant=x2, level=2, process=1, rescale=FALSE) ### Create Shepard diagram shepard(op.scaled) ### Same results are produced by: shep.plot(op.scaled$quant, op.scaled$os)
opscale
Calculates stress coefficients summarizing lack of fit between two vectors.
stress(x, ...) calc.stress(quant, os, rescale = FALSE, os.raw.mean = mean(os, na.rm = TRUE), os.raw.sd = sd(os, na.rm = TRUE))
stress(x, ...) calc.stress(quant, os, rescale = FALSE, os.raw.mean = mean(os, na.rm = TRUE), os.raw.sd = sd(os, na.rm = TRUE))
x |
Object of class |
quant |
Data vector. |
os |
Vector of optimally-scaled data |
rescale |
If TRUE, the optimally-scaled data have been rescaled to the mean and standard deviation of the original qualitative data vector that was used in the optimal scaling transformation. |
os.raw.mean |
User-specified mean for optimally-scaled data, defaults to mean of |
os.raw.sd |
User-specified standard deviation for optimally-scaled data, defaults to
standard deviation of |
... |
Ignored |
stress()
and calc.stress()
both
produce a vector with three elements:
stress1 |
Kruskals Stress 1 coefficient |
stress2 |
Kruskals Stress 2 coefficient |
raw.stress |
Sum of squared residuals between |
If using calc.stress()
, the
stress coefficients must be created using "raw" optimally scaled values.
That is, the OS values should NOT be rescaled to the mean and standard
deviation of the original qualitative data.
### x1 is vector of qualitative data ### x2 is vector of quantitative values x1 <- c(1,1,1,1,2,2,2,3,3,3,3,3,3) x2 <- c(3,2,2,2,1,2,3,4,5,2,6,6,4) ### Optimal scaling, specifying that x1 ### is ordinal-discrete, optimally scaled ### values are not rescaled op.scaled <- opscale(x.qual=x1, x.quant=x2, level=2, process=1, rescale=FALSE) ### Calculate stress coefficients stress(op.scaled) ### Same results can be obtained with: calc.stress(op.scaled$quant, op.scaled$os)
### x1 is vector of qualitative data ### x2 is vector of quantitative values x1 <- c(1,1,1,1,2,2,2,3,3,3,3,3,3) x2 <- c(3,2,2,2,1,2,3,4,5,2,6,6,4) ### Optimal scaling, specifying that x1 ### is ordinal-discrete, optimally scaled ### values are not rescaled op.scaled <- opscale(x.qual=x1, x.quant=x2, level=2, process=1, rescale=FALSE) ### Calculate stress coefficients stress(op.scaled) ### Same results can be obtained with: calc.stress(op.scaled$quant, op.scaled$os)