Title: | Constrained Dual Scaling for Detecting Response Styles |
---|---|
Description: | This is an implementation of constrained dual scaling for detecting response styles in categorical data, including utility functions. The procedure involves adding additional columns to the data matrix representing the boundaries between the rating categories. The resulting matrix is then doubled and analyzed by dual scaling. One-dimensional solutions are sought which provide optimal scores for the rating categories. These optimal scores are constrained to follow monotone quadratic splines. Clusters are introduced within which the response styles can vary. The type of response style present in a cluster can be diagnosed from the optimal scores for said cluster, and this can be used to construct an imputed version of the data set which adjusts for response styles. |
Authors: | Pieter Schoonees [aut, cre] |
Maintainer: | Pieter Schoonees <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0.3 |
Built: | 2024-10-25 02:44:11 UTC |
Source: | https://github.com/cran/cds |
Fit constrained dual scaling for detecting response styles.
Pieter C. Schoonees
Departmental report available
Schoonees, P.C., Velden, M. van de & Groenen, P.J.F. (2013). Constrained Dual Scaling for Detecting Response Styles in Categorical Data. (EI report series EI 2013-10). Rotterdam: Econometric Institute.
Adds q - 1
boundaries between the q
ratings to the columns of
matrix x
, and convert the rows to rankings, starting with 0 for the
lowest ranking. Ties are handled by averaging the total rank for all
tied observations.
addbounds(x, q = max(x), ties = "average")
addbounds(x, q = max(x), ties = "average")
x |
matrix (or data frame) of |
q |
scalar; the number of rating scale categories. Defaults to the
maximum entry in |
ties |
character; handling of ties in |
Any x
which is not a matrix or data frame will cause an error.
A matrix of size n
by m + q - 1
Pieter C. Schoonees
set.seed(1234) mat <- matrix(sample(1:9, 12, replace = TRUE), nrow = 4, ncol = 3) addbounds(mat, q = 9)
set.seed(1234) mat <- matrix(sample(1:9, 12, replace = TRUE), nrow = 4, ncol = 3) addbounds(mat, q = 9)
Uses the eigendecomposition of a square, symmetrix matrix R to obtain the
loadings matrix L such that R is approximated by LL', with L restricted to
have r
columns. Hence LL' is a rank r
approximation of R. The
eigendecomposition of R is used to obtain L from the first r
eigenvectors and eigenvalues. In case procr.target
is not
NULL
, L is further rotated through orthogonal Procrustes analysis to
match as closely as possible the matrix procr.target
through
orthprocr
.
approxloads(R, r = 3, procr.target = NULL, refl.target = NULL)
approxloads(R, r = 3, procr.target = NULL, refl.target = NULL)
R |
Square, symmetric matrix R to be approximated |
r |
The required rank of the approximation |
procr.target |
Optional; the target matrix for L in the orthogonal Procrustes analysis |
refl.target |
Optional; the matrix to check against for possible reflections of the loading vectors. |
R <- rcormat(10, r = 3) all.equal(R$L, approxloads(R$R, r = 3, procr.target = R$L))
R <- rcormat(10, r = 3) all.equal(R$L, approxloads(R$R, r = 3, procr.target = R$L))
Calculate weights for the bubbles in the plot method of cds
objects. The relative
frequencies within a dset of groups are used to calculate the size of the bubble so that the area
of the bubble is proportional to the relative frequency of the rating category within that group.
calc.wt.bubbles(dat, grp, q, fact = 0.12)
calc.wt.bubbles(dat, grp, q, fact = 0.12)
dat |
A data set from which to derive the relative frequencies |
grp |
A vector giving the group memberships. |
q |
An integer such that the rating scale is |
fact |
A schrinkage factor. |
Pieter Schoonees
Uses an alternating nonnegative least squares algorithm combined with a k-means-type algorithm to optimize the constrained group dual scaling criterion outlined in the reference. Parallel computations for random starts of the grouping matrix is supported via package parallel.
cds(x, K = 4, q = NULL, eps.ALS = 0.001, eps.G = 1e-07, nr.starts.G = 20, nr.starts.a = 5, maxit.ALS = 20, maxit = 50, Gstarts = NULL, astarts = NULL, parallel = FALSE, random.G = FALSE, times.a.multistart = 1, info.level = 1, mc.preschedule = TRUE, seed = NULL, LB = FALSE, reorder.grps = TRUE, rescale.a = TRUE, tol = sqrt(.Machine$double.eps), update.G = TRUE)
cds(x, K = 4, q = NULL, eps.ALS = 0.001, eps.G = 1e-07, nr.starts.G = 20, nr.starts.a = 5, maxit.ALS = 20, maxit = 50, Gstarts = NULL, astarts = NULL, parallel = FALSE, random.G = FALSE, times.a.multistart = 1, info.level = 1, mc.preschedule = TRUE, seed = NULL, LB = FALSE, reorder.grps = TRUE, rescale.a = TRUE, tol = sqrt(.Machine$double.eps), update.G = TRUE)
x |
an object of class |
K |
The number of response style groups to look for. If a vector of
length greater than one is given, the algorithm is run for each element
and a list of class |
q |
The maximum rating (the scale is assumed to be |
eps.ALS |
Numerical convergence criterion for the alternating least squares part of the algorithm (updates for row and column scores). |
eps.G |
Numerical convergence criterion for the k-means part of the algorithm. |
nr.starts.G |
Number of random starts for the grouping matrix. |
nr.starts.a |
Number of random starts for the row scores. |
maxit.ALS |
Maximum number of iterations for the ALS part of the algorithm. A warning is given if this maximum is reached. Often it is not a concern if this maximum is reached. |
maxit |
Maximum number of iterations for the k-means part of the algorithm. |
Gstarts |
Facility to supply a list of explicit starting values for the
grouping matrix G. Each start consists of a two element list: |
astarts |
Supply explicit starts for the a vectors, as a list. |
parallel |
logical. Should parallelization over starts for the grouping matrix be used? |
random.G |
logical. Should the k-means part consider the individuals in a random order? |
times.a.multistart |
The number of times that random starts for the row scores are used. If == 1, then random starts are only used once for each start of the grouping matrix. |
info.level |
Verbosity of the output. Options are 1, 2, 3 and 4. |
mc.preschedule |
Argument to mclapply under Unix. |
seed |
Random seed for random number generators. Only partially implemented. |
LB |
logical. Load-balancing used in parallelization or not? Windows only. |
reorder.grps |
logical. Use the Hungarian algorithm to reorder group names so that the trace of the confusion matrix is maximized. |
rescale.a |
logical. Rescale row score to length sqrt(2n) if TRUE (after the algorithm has converged). |
tol |
tolerance |
update.G |
Logical indicating whether or not to update the G matrix from its starting configuration. Useful when clustering is known apriori or not desired. |
See the reference for more details.
Object of class ds
with elements:
G |
Grouping indicator matrix. |
K |
Number of groups K. |
opt.crit |
Optimum value of the criterion. |
a |
The 2n-vector of row scores. |
bstar |
The m-vector of object scores. |
bkmat |
The matrix of group-specific boundary scores for the ratings. |
alphamat |
The estimated spline coefficients for each group. |
iter |
The number of iterations used for the optimal random start wrt the grouping matrix. |
time.G.start |
The number of seconds it took for the algorithm to converge for this optimal random start. |
grp |
The grouping of the individuals as obtained by the algorithm. |
kloss |
Loss value from G update (not equivalent to that of ALS updates). |
hitrate , confusion
|
Confusion and hitrates of original data object contained a grouping vector. |
loss.G |
Optimality criterion values for the random starts of G. |
q |
The number of ratings in the
Likert scale |
time.total |
Total time taken for the algorithm over all random starts |
call |
The function call. |
data |
The input data object. |
Pieter C. Schoonees
Schoonees, P.C., Velden, M. van de & Groenen, P.J.F. (2013). Constrained Dual Scaling for Detecting Response Styles in Categorical Data. (EI report series EI 2013-10). Rotterdam: Econometric Institute.
set.seed(1234) dat <- cds.sim() out <- cds(dat)
set.seed(1234) dat <- cds.sim() out <- cds(dat)
Simulate response data for a group of response styles.
cds.sim(nr.indv = c(100, 100, 100), m = 25, scales = 1:7, err.coeff = 0.1, alphamat = rbind(c(4, 4, 1), c(1, 4, 4), c(1, 2, 1)), true.mu = NULL, random = TRUE, same.mu = TRUE, use.copula = FALSE, reverse.thresh = 1)
cds.sim(nr.indv = c(100, 100, 100), m = 25, scales = 1:7, err.coeff = 0.1, alphamat = rbind(c(4, 4, 1), c(1, 4, 4), c(1, 2, 1)), true.mu = NULL, random = TRUE, same.mu = TRUE, use.copula = FALSE, reverse.thresh = 1)
nr.indv |
A vector giving the number of respondents in each group. |
m |
The number of objects. |
scales |
The rating scale used, 1:q. |
err.coeff |
The standard error used in the underlying normal noise. |
alphamat |
The matrix of spline parameters defining the response styles, with each row containing a response style. No intercepts should be included. |
true.mu |
Optional; a matrix or vector giving the true underlying preferences for the objects. |
random |
Logical indicating whether to apply the response styles in random order |
same.mu |
Logical indicating whether a universal value for mu should be assumed. |
use.copula |
Logical indicating whether to use a correlated dependence structure through a copula. |
reverse.thresh |
A numeric value giving the proportion of observations for which the
dependece structure should be reversed. Only applicable when |
An object of class cdsdata
, inheriting from class icdsdata
, which is a
list with the following slots:
The pre-response style simulated data
The data after adding the response styles
The same as postrs
in this case
The centred Fr matrix for postrs
The Fr matrix for postrs
The same as Fr.cent.rs
, for compatibility with icds
The same as Fr.rs
, for compatibility with icds
Matrix of the true underlying preference structure for the obects
Numeric vector identifying the different blocks for incompleteness, in this case a vector of ones
The response style grouping vector
Matrix of spline parameters for the response styles
The rating scale 1:q used
Number of objects
The number of objects seen within each block - equal to zero in this case
The number of objects seen by all subjects - equal to m
in this case
Actual tau used in the simulation with copulae
The function call
These methods integrate the class cds
into the framwork set out in
package clue. Use can therefore by made of cl_agreement
to
calculate concordance measures between different solutions.
## S3 method for class 'cds' cl_class_ids(x) ## S3 method for class 'cds' is.cl_partition(x) ## S3 method for class 'cds' is.cl_hard_partition(x) ## S3 method for class 'cdsdata' cl_class_ids(x) ## S3 method for class 'cdsdata' is.cl_partition(x) ## S3 method for class 'cdsdata' is.cl_hard_partition(x)
## S3 method for class 'cds' cl_class_ids(x) ## S3 method for class 'cds' is.cl_partition(x) ## S3 method for class 'cds' is.cl_hard_partition(x) ## S3 method for class 'cdsdata' cl_class_ids(x) ## S3 method for class 'cdsdata' is.cl_partition(x) ## S3 method for class 'cdsdata' is.cl_hard_partition(x)
x |
An object of class |
Replace original ratings with optimal scores based on cds
output..
clean.scales(object, data, K, col.subset = NULL, ...) ## S3 method for class 'cds' clean.scales(object, data, K, col.subset = NULL, ...) ## S3 method for class 'cdslist' clean.scales(object, data, K, col.subset = NULL, ...)
clean.scales(object, data, K, col.subset = NULL, ...) ## S3 method for class 'cds' clean.scales(object, data, K, col.subset = NULL, ...) ## S3 method for class 'cdslist' clean.scales(object, data, K, col.subset = NULL, ...)
object |
An object of class |
data |
An object of class |
K |
The number of classes in the solution that must be kept. |
col.subset |
An optional subset |
... |
Additional arguments. |
Create an indicator matrix.
create.ind(grp)
create.ind(grp)
grp |
A grouping vector. |
Creates a response style by cutting up a quadratic monotone spline.
create.rs(alpha = matrix(c(1, 2, 1), nrow = 1), nr.scale = 7, tvec = c(0, 0.5, 1), xvec = 0:nr.scale/nr.scale, scale = TRUE)
create.rs(alpha = matrix(c(1, 2, 1), nrow = 1), nr.scale = 7, tvec = c(0, 0.5, 1), xvec = 0:nr.scale/nr.scale, scale = TRUE)
alpha |
vector of spline coefficients |
nr.scale |
number of rating categories; numeric |
tvec |
knots for spline functions |
xvec |
evaluation points for basis functions |
scale |
logical; scale or not |
Pieter C. Schoonees
Create a cdsdata object from a data frame or matrix.
createcdsdata(x, q = NULL)
createcdsdata(x, q = NULL)
x |
A data frame or matrix containing the data. |
q |
Optional; the maximum rating category, so that the rating scale used for all
items are |
Simulate data containing a single repsponse style.
datsim(nr.indv = 100, m = 5, scales = 1:7, err.coeff = 0.1, resp.style = c(-Inf, 1/7, 2/7, 3/7, 4/7, 5/7, 6/7, Inf), true.mu = NULL, a = 0, b = 1, plot.graph = FALSE, use.copula = FALSE, reverse.thresh = 1, ...)
datsim(nr.indv = 100, m = 5, scales = 1:7, err.coeff = 0.1, resp.style = c(-Inf, 1/7, 2/7, 3/7, 4/7, 5/7, 6/7, Inf), true.mu = NULL, a = 0, b = 1, plot.graph = FALSE, use.copula = FALSE, reverse.thresh = 1, ...)
nr.indv |
Integer giving the number of individuals required in the sample. |
m |
The number of items. |
scales |
The rating scale used for all items. |
err.coeff |
The standard error used in simulating the truncated normal distribution. |
resp.style |
A set of cut points across the interval [0, 1] defining the response style transformation. |
true.mu |
Optional vector of length |
a |
Lower boundary of the truncation interval for the simulated true preferences. |
b |
Upper boundary for the truncation interval for the simulated true preferences. |
plot.graph |
Logical indicating whether to visualize the response style in a plot. |
use.copula |
Logical indicating whether to simulate dependent items using a copula. |
reverse.thresh |
A proportion giving the proportion of item preferences which should be reversed to induce a negative association. |
... |
Additional arguments passed to |
Pieter C. Schoonees
Schoonees, P.C., Velden, M. van de & Groenen, P.J.F. (2013). Constrained Dual Scaling for Detecting Response Styles in Categorical Data. (EI report series EI 2013-10). Rotterdam: Econometric Institute.
Run algorithm for a single G matrix.
G.start(X, nr.starts.a, astarts, maxit, n, m, q, Fr.cent, maxit.ALS, Mmat, eps.G, info.level, times.a.multistart, eps.ALS, const, K, random.G, tol, update.G)
G.start(X, nr.starts.a, astarts, maxit, n, m, q, Fr.cent, maxit.ALS, Mmat, eps.G, info.level, times.a.multistart, eps.ALS, const, K, random.G, tol, update.G)
X |
List of two elements, namely |
nr.starts.a |
The number or random starts for |
astarts |
Explicit starts for a, if applicable. |
maxit |
The maximum number of iterations with respect to G. |
n |
The number of respondents. |
m |
The number of items. |
q |
The maximum rating category such that the rating scale is |
Fr.cent |
The centred Fr matrix. |
maxit.ALS |
The maximum number of ALS iterations. |
Mmat |
The basis matrix for the quadratic monotone splines. |
eps.G |
The absolute error tolerance for the G updates. |
info.level |
Integer controlling the amount of information printed. |
times.a.multistart |
The number of times random starts for |
eps.ALS |
The absolute error tolerance for the ALS. |
const |
The constant part of the loss function. |
K |
The number of groups. |
random.G |
The |
tol |
tolerance |
update.G |
Logical indicating whether or not to update the starting configuration
|
Generate correlated data multivariate categorical data via a copula.
gen.cop(n, tauvek = c(0.2, 0.35), nr.cols = c(10, 10), true.mu = runif(sum(nr.cols)), err.coeff = 0.1, random = FALSE, reverse = TRUE, reverse.thresh = 0.75)
gen.cop(n, tauvek = c(0.2, 0.35), nr.cols = c(10, 10), true.mu = runif(sum(nr.cols)), err.coeff = 0.1, random = FALSE, reverse = TRUE, reverse.thresh = 0.75)
n |
Integer; the number of samples to draw. |
tauvek |
A vector of association parameters for each of the Clayton copulae
(see |
nr.cols |
A vector giving the number of columns to draw from each of the copulae. |
true.mu |
A vector giving the mean for each of the columns in the data. |
err.coeff |
The standard errors for underlying normal distribution. |
random |
Logical indicating whether or not the samples should be presented in random order. |
reverse |
Logical indicating whether some of the simulated variables should be reversed to have negative association or not. |
reverse.thresh |
The proportion of columns to reverse. |
Generate a response style data set from a specific correlation matrix, clean the data with constrained dual scaling and report the original, cleaned and contaminated correlation matrices in a list.
genPCA(nr.indv = rep(100, 5), m = 10, q = 7, r = 3, err.coeff = 0.1, alphamat = rbind(c(0.5, 2, 4), c(10, 2, 10), c(1, 2, 1), c(4, 2, 0.5), c(0.1, 2, 0.1))[1:length(nr.indv), ], randomize = TRUE, ...)
genPCA(nr.indv = rep(100, 5), m = 10, q = 7, r = 3, err.coeff = 0.1, alphamat = rbind(c(0.5, 2, 4), c(10, 2, 10), c(1, 2, 1), c(4, 2, 0.5), c(0.1, 2, 0.1))[1:length(nr.indv), ], randomize = TRUE, ...)
nr.indv |
Vector; number of individuals in each response style group.
It is passed to |
m |
scalar; Number of items. |
q |
scalar; Number of rating categories, such that the rating scale is
|
r |
scalar; Rank of simulated correlation matrices. |
err.coeff |
scalar; Standard deviation used in simulations that is
passed on to |
alphamat |
matrix; Contains the spline parameters for the different
response styles that is passed to |
randomize |
logical; See |
... |
Arguments passed to |
A list with components:
Rsim |
Correlation matrix from which the sample was generated |
Rclean |
Correlation matrix for the cleaned data |
Rcont |
Correlation matrix for the contaminated data |
Pieter C. Schoonees
Alternating least-sqaures for estimating row and column scores in constrained dual scaling, where different groups are allowed for.
group.ALS(a, m, q, G, Fr.cent, eps = 0.1, maxit = 50, Mmat, info.level = 2, const, K, n, tol)
group.ALS(a, m, q, G, Fr.cent, eps = 0.1, maxit = 50, Mmat, info.level = 2, const, K, n, tol)
a |
A |
m |
Integer; the number of items. |
q |
Integer; the rating scale from |
G |
An indicator matrix of size |
Fr.cent |
The centred F_r matrix. |
eps |
The numerical tolerance level for the loss. |
maxit |
Integer; the maximum number of iterations allowed. |
Mmat |
Matrix of spline basis functions. |
info.level |
Integer controlling the amount of information printed. |
const |
The constant part of the loss function. |
K |
The number of latent classes. |
n |
The number of samples. |
tol |
tolerance |
Creates an indicator matrix from a grouping vector.
indmat(grp.vec, K = length(unique(grp.vec)))
indmat(grp.vec, K = length(unique(grp.vec)))
grp.vec |
Numeric vector giving the group membership. |
K |
Scalar indicating the number of groups. Defaults to the number of
unique elements in |
Calculate basis functions for monotone quadratic splines.
ispline(xvec, tvec = c(0, 0.5, 1), intercept = TRUE)
ispline(xvec, tvec = c(0, 0.5, 1), intercept = TRUE)
xvec |
Vector at which to evaluate the basis functions. |
tvec |
Vector of spline knots: lower endpoint, interior knot, upper endpoint. |
intercept |
Logical; should an intercept be included or not? |
Calculate the loss function for constrained dual scaling.
Lfun(a.cur, bkmat, G, Fr.cent, n, m, q, const, K)
Lfun(a.cur, bkmat, G, Fr.cent, n, m, q, const, K)
a.cur |
The current value for a. |
bkmat |
Current value of bkmat. |
G |
Current value G. |
Fr.cent |
Current value of the centred Fr. |
n |
Number of respondents. |
m |
Number of items. |
q |
Number for rating scale categories so that the rating scale is |
const |
Constant part of the loss function |
K |
Number of response style groups. |
Loss function used for updating G. This is not equivalent to the original loss function, as only a part of the total loss depends on G.
Lfun.G.upd(G, a.cur, bwts2, Fr.bk, n, m, q, K)
Lfun.G.upd(G, a.cur, bwts2, Fr.bk, n, m, q, K)
G |
The current value for G. |
a.cur |
The current value for a. |
bwts2 |
The current value of the squared b weights. |
Fr.bk |
Current product between Fr.cent and bk. |
n |
Number of respondents. |
m |
Number of items. |
q |
Number for rating scale categories so that the rating scale is |
K |
Number of response style groups. |
Simple function to rotate matrix X so that it matches the target matrix Z as closely as possible, by minimizing ||Z - XQ|| where Z and X are of the same size and Q is an orthogonal matrix. The algorithm is based on the singular value decomposition (SVD) (see e.g. the reference).
orthprocr(Z, X)
orthprocr(Z, X)
Z |
The target matrix |
X |
The matrix to be rotated, which must be of the same size as Z. |
A list with the following 2 elements:
Q |
The rotation matrix |
XQ |
The matrix X after rotation |
Gower, J. C. and Hand, D.J. (1996). Biplots (Vol. 54). CRC Press.
Plot method for cds
objects
## S3 method for class 'cds' plot(x, which = 1L:3L, type = "l", lty = 1, lwd = 2, show.legend = TRUE, col = colorspace::rainbow_hcl(nr), bty.legend = "n", intercept = ncol(x$alphamat) == 4, scale = FALSE, add = FALSE, exp.factor = 1.2, bubble.fact = 0.12, cont.factor = 0.01, pch = 15, ...)
## S3 method for class 'cds' plot(x, which = 1L:3L, type = "l", lty = 1, lwd = 2, show.legend = TRUE, col = colorspace::rainbow_hcl(nr), bty.legend = "n", intercept = ncol(x$alphamat) == 4, scale = FALSE, add = FALSE, exp.factor = 1.2, bubble.fact = 0.12, cont.factor = 0.01, pch = 15, ...)
x |
An object of class |
which |
A numeric vector: a subset of |
type |
Passed to |
lty |
Passed to |
lwd |
Passed to |
show.legend |
Logical; should a legend be added to the plot or not. |
col |
Passed to |
bty.legend |
Passed to |
intercept |
Logical indicating whether to plot the intercept. |
scale |
Logical indicating whether an intercept should be included or not. |
add |
Logical; add to plot or not? |
exp.factor |
Factor for expanding the x- and y-limits. |
bubble.fact |
Passed to |
cont.factor |
Continuity correction to apply in case one of the alpha's are equal to zero. |
pch |
Plotting character to use. |
... |
Additional arguments passed to |
cdslist
ObjectCreate a scree plot and bubble plots for all elements in a cdslist
object.
## S3 method for class 'cdslist' plot(x, which = 2L, ...)
## S3 method for class 'cdslist' plot(x, which = 2L, ...)
x |
An object of class |
which |
The which argument passed to |
... |
Additional arguments passed to |
Print method for cds
objects.
## S3 method for class 'cds' print(x, ...)
## S3 method for class 'cds' print(x, ...)
x |
A |
... |
Unimplemented. |
This is a simple print method for object that inherits from the class cdsdata
.
## S3 method for class 'cdsdata' print(x, ...)
## S3 method for class 'cdsdata' print(x, ...)
x |
A |
... |
Unimplemented. |
Generate a correlation matrix as R = LL' where the rows of L are of length
1, L is of rank r
and the matrix L is sparse (depending on
sparse.prop
. The loadings in L are sampled from a standard normal
distribution, after which sparse.prop
is used to set a randomly
chosen number of loadings in each row equal to zero. To ensure that a
correlation matrix results, the rows are normalized.
rcormat(m, r = 3L, sparse.prop = 0.5)
rcormat(m, r = 3L, sparse.prop = 0.5)
m |
integer; the number of variables. |
r |
integer; the required rank. |
sparse.prop |
the proportion of zeros in the rows of the matrix. |
A list with the following components:
R |
The sampled correlation matrix |
L |
The loading matrix |
R <- rcormat(m = 10)$R eigen(R)
R <- rcormat(m = 10)$R eigen(R)
Construct a low-rank covariance matrix with specified eigenvalues, where the eigenvectors are simulated from uniform distributions.
rcovmat(eigs = k:1, m = 10, k = 2, perc = list(c(0.4, 0.2, 0.4), c(0.2, 0.4, 0.4)), limits = list(l1 = c(0.5, 1), l2 = c(-1, -0.5), l3 = c(-0.1, 0.1)), random = TRUE)
rcovmat(eigs = k:1, m = 10, k = 2, perc = list(c(0.4, 0.2, 0.4), c(0.2, 0.4, 0.4)), limits = list(l1 = c(0.5, 1), l2 = c(-1, -0.5), l3 = c(-0.1, 0.1)), random = TRUE)
eigs |
Vector of $k$ eigenvalues. |
m |
Integer; the number of rows and columns of the matrix. |
k |
Integer; the rank of the matrix. |
perc |
List of $k$ vectors giving the sampling proportions for the uniform sampling of the eigenvectors, for each dimension. |
limits |
List of length 2 vectors, one for each uniform sample, giving the lower and upper bounds of the uniform distribution. |
random |
Logical; randomize the order of the loading per dimension or not. |
Data from 268 panellists rating each of 20 different products on 7 attributes. It is presented
in a data.frame
with 268 observations on 140 variables. Each observation
represents a different trained panellist. The columns correspond to products and items.
The 20 different products are coded by alphabetic letters from A to T, and the items are coded
from 1 to 7. So item C5 corresponds to product C being rated on item 5.
data(sensory)
data(sensory)
sensory
DataAuxiliary Information for sensory
Data
A data frame with 268 observations on the following 3 variables.
a factor with levels F
for females
and M
for males
a factor for age with levels
14 to 24
,25 to 34
, 35 to 44
, and 45 to 55
a factor for consumption with levels Heavy
consumer
, Light consumer
, and Medium consumer
obtained ~~
data(sensory.aux)
data(sensory.aux)
Simulate normally distributed data with specific covariance structure and randomly sampled means. Adds response style contamination.
simpca(nr.indv = rep(200, 5), m = 10, q = 7, R = rcormat(m = m), err.coeff = 0.1, alphamat = rbind(c(0.5, 2, 4), c(10, 2, 10), c(1, 2, 1), c(4, 2, 0.5), c(0.1, 2, 0.1))[1:length(nr.indv), ], randomize = FALSE)
simpca(nr.indv = rep(200, 5), m = 10, q = 7, R = rcormat(m = m), err.coeff = 0.1, alphamat = rbind(c(0.5, 2, 4), c(10, 2, 10), c(1, 2, 1), c(4, 2, 0.5), c(0.1, 2, 0.1))[1:length(nr.indv), ], randomize = FALSE)
nr.indv |
Numeric vector of group sizes. |
m |
Integer; then number of variables to simulate. |
q |
Integer; the rating scale used |
R |
List with entry named 'R' which is the simulated correlation matrix |
err.coeff |
Standard error for each variable, added unto |
alphamat |
Matrix containing splines coefficients for te construction of respone styles. |
randomize |
logical; should the rows of the data be randomly permuted or not? |
Quantile function of the truncated normal distribution.
trQnorm(p, mean = 1, sd = 1, a = 0, b = 1)
trQnorm(p, mean = 1, sd = 1, a = 0, b = 1)
p |
Vector of probabilities. |
mean |
The mean of the distribution. |
sd |
The standard deviation. |
a |
Lower truncation point. |
b |
Upper truncation point. |
Pieter C. Schoonees
Random numbers from truncated univariate normal.
trRnorm(n, mu = 0, sd = 1, a = -Inf, b = Inf)
trRnorm(n, mu = 0, sd = 1, a = -Inf, b = Inf)
n |
The number of points to sample. |
mu |
The mean of the distribution. |
sd |
The standard deviation. |
a |
The lower truncation point. |
b |
The upper truncation point. |
Updates the grouping matrix.
updateG(G, a, bwts2, Fr.bk, const, n, m, q, random = FALSE, info.level = 3)
updateG(G, a, bwts2, Fr.bk, const, n, m, q, random = FALSE, info.level = 3)
G |
Grouping matrix. |
a |
Current value of the row scores. |
bwts2 |
Squared column weights. |
Fr.bk |
Product of Fr and bkmat. |
const |
Constant part of the loss function. |
n |
The number of observations. |
m |
The number of items. |
q |
The number of rating categories. |
random |
Logical indicating whether to randomize the observations. |
info.level |
Integer controlling the amount of printed. |
Pieter Schoonees