Package 'Gifi'

Title: Multivariate Analysis with Optimal Scaling
Description: Implements categorical principal component analysis ('PRINCALS'), multiple correspondence analysis ('HOMALS'), monotone regression analysis ('MORALS'). It replaces the 'homals' package.
Authors: Patrick Mair [aut, cre], Jan De Leeuw [aut], Patrick J. F. Groenen [ctb]
Maintainer: Patrick Mair <[email protected]>
License: GPL-3
Version: 0.4-0
Built: 2024-11-15 05:06:34 UTC
Source: https://github.com/r-forge/psychor

Help Index


ABC Customer Satisfaction

Description

The ABC Company (a fictitious company) is a typical global supplier of integrated software, hardware, and services solutions to media and telecommunications service providers. The company develops, installs and maintains systems combining hardware, software and advanced electronics. These enabling systems support various lines of business, including Video on Demand, cable, and satellite TV, as well as a range of communications services, such as voice, video, data, Internet protocol, broadband, content, electronic, and mobile commerce. They launched an customer satisfaction survey designed to provide feedback on all company touch points and interactions with customers. It covers topics such as Equipment, Sales Support, Technical Support, Training, Supplies, Software Solutions, Customer Portal, Administrative Support, Terms, Conditions and Pricing and Site Planning and Installation.

Usage

ABC

Format

Data frame with 11 items on a 5-point Likert scale (except one item, see below)

satis:

Overall satisfaction level from ABC. (1 ... very low, 5 ... very high)

satis2010:

Overall satisfaction level from ABC's improvements during 2010. (1 ... very low, 5 ... very high)

best:

Is ABC your best supplier? (0 ... no; 1 ... yes)

recom:

Would you recommend ABC to other companies? (1 ... very unlikely, 5 ... very likely)

product:

If you were in the market to buy a product, how likely would it be for you to purchase an ABC product again? (1 ... very unlikely, 5 ... very likely)

equipment:

Overall satisfaction level from the equipment. (1 ... very low, 5 ... very high)

sales:

Overall satisfaction level from sales support. (1 ... very low, 5 ... very high)

technical:

Overall satisfaction level from technical support. (1 ... very low, 5 ... very high)

training:

Overall satisfaction level from ABC training. (1 ... very low, 5 ... very high)

purchase:

Overall satisfaction level from purchasing support. (1 ... very low, 5 ... very high)

pricing:

Overall satisfaction level from pricing and contracts. (1 ... very low, 5 ... very high)

References

Kenett, R. S., & Salini, S. (2012). Modern Analysis of Customer Surveys with Applications in R. New York: Wiley.

Examples

head(ABC)

Cross-validation for Morals fit

Description

Performs a k-fold CV on Morals objects and returns the CV error.

Usage

cv(object, folds = 10, verbose = FALSE, ...)

Arguments

object

Object of class "morals"

folds

Number of folds for cross-validation (for LOOCV set it equal to n).

verbose

If TRUE, iteration is printed out

...

Additional arguments (ignored here)

Examples

## mimic linear regression
xknots <- knotsGifi(neumann[,1:2], "E")  
yknots <- knotsGifi(neumann[,3], "E")
fitlin <-  morals(neumann[,1:2], neumann[,3], xknots = xknots, yknots = yknots, 
                  xdegrees = 1, ydegrees = 1, xordinal = FALSE, yordinal = FALSE)
cv(fitlin)  ## CV error of prediction

GALO dataset

Description

The objects (individuals) are 1290 school children in the sixth grade of elementary school in the city of Groningen (Netherlands) in 1959.

Usage

galo

Format

Data frame with the five variables Gender, IQ, Advice, SES and School. IQ (original range 60 to 144) has been categorized into 9 ordered categories and the schools are enumerated from 1 to 37.

SES:

LoWC = Lower white collar; MidWC = Middle white collar; Prof = Professional, Managers; Shop = Shopkeepers; Skil = Schooled labor; Unsk = Unskilled labor.

Advice:

Agr = Agricultural; Ext = Extended primary education; Gen = General; Grls = Secondary school for girls; Man = Manual, including housekeeping; None = No further education; Uni = Pre-University.

References

Peschar, J.L. (1975). School, Milieu, Beroep. Groningen: Tjeek Willink.

Examples

data(galo)
   galo

Guttman-Bell dataset

Description

This dataset deals with attitudes of social groups.

Usage

gubell

Format

The data frame consists of 7 objects and 5 variables with a total of 17 categories.

References

Guttman, L. (1968), A General Nonmetric Technique for Fitting the Smallest Coordinate Space for a Configuration of Points, Psychometrika, 33, 469-506.

Examples

data(gubell)
   gubell

Hartigan's Hardware

Description

A number of bolts, nails, screws, and tacks are classified according to a number of criteria.

Usage

hartigan

Format

A data frame with the following variables and categories:

Thread: Y = Yes, N = No

Head: F = Flat, C = Cup, O = Cone, R = Round, Y = Cylinder

Head indentation: N = None, T = Star, L = Slit

Bottom: S = Sharp, F = Flat

Length: (in half inches)

Brass: Y = Yes, N = No

References

Hartigan, J.A. (1975). Clustering Algorithms. New York: Wiley.

Examples

data(hartigan)
   hartigan

Multiple Correspondence Analysis (HOMALS).

Description

Fits a multiple correspondence analysis (MCA). The default is to take each input variable as nominal. Through restrictions on the transformations (ordinal in conjunction with splines) various generalizations of MCA can be achieved.

Usage

homals(data, ndim = 2, levels = "nominal", ordinal, knots, ties = "s", 
degrees = -1, missing = "s", normobj.z = TRUE, active = TRUE, itmax = 1000, 
eps = 1e-6, verbose = FALSE)

Arguments

data

Input data frame: n observations, m variables

ndim

Number of dimensions to be computed

levels

A vector of length m denoting basic scale levels ("nominal", "ordinal", "metric"; see details

ordinal

If knots are specified manually, a boolean vector of length m denotes which variables should be ordinally restricted or not (see details)

knots

Scale levels can be specified manually using splines (see knotsGifi). If knots is set, this overrides level (see details)

ties

How ties should be handled: primary ("p"), secondary ("s"), or tertiary ("t")

degrees

Spline degrees. If different degrees should be used across variables, a vector of length m can be specified. The default value of -1 indicates nominal scale level (overrides the ordinal argument).

missing

How missing values should be handled: multiple ("m"), single ("s"), or average ("a")

active

Which variables should be active or inactive (also as vector of length m)

normobj.z

If TRUE, object scores are z-scores, if FALSE, they are restriction to SS of 1.

itmax

Maximum number of iterations

eps

Convergence criterion

verbose

Iteration printout

Details

The measurement (or scale) levels of the variables are incorporated via spline transformations. If the user only needs simple scale levels like nominal, ordinal, and metric, a corresponding vector can be specified in the levels argument without setting knots and ordinal. The corresponding spline transformations (unrestricted, monotone, and linear) are then created internally. If all scale level transformations are the same, ordinal can be a single value. For more advanced transformations such as polynomial or more flexible splines, the knots and ordinal arguments need to be specified instead of levels.

Value

transform

Optimally transformed scores

rhat

Induced correlation matrix

evals

Eigenvalues of induced correlation matrix

objectscores

Object scores (rows)

scoremat

Optimally scaled data matrix (first dimension)

quantifications

Category quantifications

dmeasures

Discimination matrices

lambda

Average discrimination matrix

weights

Component weights

loadings

Component loadings

ntel

Number of iterations

f

Loss function value

data

Original data frame

datanum

Numerical data frame

ndim

Number of extracted dimensions

call

Function call

References

Gifi, A. (1990). Nonlinear Multivariate Analysis. New York: Wiley.

De Leeuw, J., Mair, P., Groenen, P. J. F. (2017). Multivariate Analysis with Optimal Scaling.

See Also

princals, plot.homals

Examples

## multiple CA 
fithart <- homals(hartigan)
fithart
summary(fithart)

House

Description

The votes selected cover a full spectrum of domestic, foreign, economic, military, environmental and social issues. We tried to select votes which display sharp liberal/conservative contrasts. In many instances we have chosen procedural votes: amendments, motions to table, or votes on rules for debate. Often these votes reveal true attitudes frequently obscured in the final votes.

Usage

house

Format

A data frame with the following variables:

Party: R = Republican, D = Democrat, I = Independent.

V1: HR 333. Bankruptcy Overhaul. Jackson-Lee (D-TX) amendment to allow debtors to deduct additional medical and child-care expenses before determining their eligibility for Chapter 7 bankruptcy status. The amendment also expands the definition of family farmer, changes the standards for calculating median income, and includes debtor privacy provisions. Rejected 160-258. March 1, 2001. A yes vote is a +.

V2: SJ Res 6. Ergonomics Rule Disapproval. Passage of the joint resolution to reverse the ergonomics workplace safety rule submitted by the Clinton Administration's Labor Department. Passed 223-206. March 7, 2001. A no vote is a +.

V3: HR 3. Income Tax Reduction. Passage of the White House's bill to lower federal income taxes by restructuring the five existing tax brackets into four - 10 percent, 15 percent, 25 percent and 33 percent. The benefits of this tax cut go disproportionately to the wealthy and to major corporations. The large cost of the legislation would jeopardize domestic spending programs aimed at middle- and low-income Americans. Passed 230-198. March 8, 2001. A no vote is a +.

V4: HR 6. Marriage Tax Reduction. Rangel (D-NY) substitute amendment to reduce taxes by $585.5 billion through 2011. This tax cut would be considerably less regressive and more equitable than the Republican version. The Rangel plan would create a new 12 percent bracket for the first $20,000 of a couple's taxable income and $10,000 for single taxpayers. It also would increase the standard deduction for married couples filing jointly to twice that of individuals filing singly. Additionally, the amendment would simplify and expand the earned-income tax credit for low-income earners. Rejected 196-231. March 29, 2001. A yes vote is a +.

V5: HR 8. Estate Tax Relief. Rangel (D-NY) substitute amendment to increase the estate tax exemption from $675,000 to $2 million ($4 million for married couples) in 2002, rising to $2.5 million by 2010. This legislation serves as an alternative to the drastic Republican abolition of the progressive estate tax. The Rangel tax cut would lower federal revenue by $39.2 billion over ten years. The amendment would retain current-law step-up basis provisions, and replace the credit for estate taxes paid to a state with a deduction. Rejected 201-227. April 4, 2001. A yes vote is a +.

V6: HR 503. Fetal Protection. Passage of the bill to make it a criminal offense to injure or kill a fetus during the commission of a violent federal crime. The measure would establish criminal penalties equal to those that would apply if the injury or death occurred to a pregnant woman, regardless of the perpetrator's knowledge of the pregnancy or intent to harm the fetus. The bill states that its provisions should not be interpreted to apply to consensual abortion or to a woman's actions with respect to her pregnancy. The death penalty could not be imposed under this bill. Passed 252-172. April 26, 2001. A no vote is a +.

V7: HR 1. School Vouchers. Armey (R-TX) amendment to provide federal funding for students to attend private schools, including religious schools, if they are currently enrolled in schools that are dangerous or have been low-performing for three years. Crime victims also would be provided with funding to attend alternative private schools. Rejected 155-273. May 23, 2001. A no vote is a +.

V8: HR 1836. Tax Cut Reconciliation Bill. Adoption of the conference report on the bill to reduce taxes by $1.35 trillion through fiscal 2011 via income tax rate cuts, relief of the marriage penalty, phaseout of the federal estate tax, doubling of the child tax credit, and new incentives for retirement savings. A new 10 percent tax rate would be created retroactive to January 1. The bill would: double the $500-per-child tax credit by 2010 and make it refundable; raise the estate tax exemption to $1 million in 2002 and repeal the tax in 2010; increase the standard deduction for married couples to double that of singles over five years, beginning in 2005; and increase annual contributions limits for Individual Retirement Accounts. The bill's provisions would expire December 31, 2010. Adopted 240-154. May 26, 2001. A no vote is a +.

V9: HR 2356. Campaign Finance Reform. Adoption of the rule to allow the House to consider a ban on soft money donations to national political parties. This rule was crafted by campaign finance reform foes to disallow amendments which fine-tune the bill and, thus, keep reform advocates from gathering more votes in support of final passage. Beyond banning soft money, the original reform legislation would allow up to $10,000 in soft-money donations to state and local parties for voter registration and get-out-the vote activity. The reform bill would prevent issue ads from targeting specific candidates within 60 days of a general election or 30 days of a primary. Additionally, the legislation would maintain the current individual contribution limit of $1,000 per election for House candidates but raise it to $2,000 for Senate candidates, both of which would be indexed for inflation. Rejected 203-228. July 12, 2001. A no vote is a +.

V10: HJ Res 36. Flag Desecration. Passage of the joint resolution proposing a Constitutional amendment to prohibit physical desecration of the U. S. flag. Passed 298-125. (A two-thirds majority vote of those present and voting - 282 in this case - is required to pass a joint resolution proposing an amendment to the Constitution.) July 17, 2001. A no vote is a +.

V11: HR 7. Faith-Based Initiative. Conyers (D-MI) motion to recommit the bill to the Judiciary Committee with instructions to add language stating that federally-funded religious service providers cannot discriminate based on religion and that no provision supercedes state or local civil rights laws. Motion rejected 195-234. July 19, 2001. A yes vote is a +.

V12: HJ Res 50. China Normalized Trade Relations. Passage of a joint resolution to deny the President's request to provide normal trade relations (formerly known as most-favored-nation trade status) for items produced in China from July 2001 through July 2002. Rejected 169-259. July 19, 2001. A yes vote is a +.

V13: HR 4. ANWR Drilling Ban. Markey (D-MA) amendment to maintain the current prohibition on oil drilling in the Arctic National Wildlife Refuge. Rejected 206-223. August 1, 2001. A yes vote is a +.

V14: HR 2563. Patients' Rights/HMO Liability. Norwood (R-GA) amendment to limit liability and damage awards when a patient is harmed by denial of health care. This amendment was offered after patients' rights opponents in the White House exerted pressure on Rep. Norwood to abandon a stronger bill. The legislation would allow a patient to sue a health maintenance organization (HMO) in state court but with federal, not state, law governing. An employer could remove cases to federal court. The bill would limit non-economic damages to $1.5 million. Punitive damages would be limited to the same amount and only allowed when a decisionmaker fails to abide by a grant of benefits by an independent medical reviewer. Adopted 218-213. August 2, 1001. A no vote is a +.

V15: HR 2563. Patients' Bill of Rights. Passage of the bill to provide federal health care protections, such as access to specialty and emergency room care, and require that health maintenance organizations (HMOs) have an appeals process for patients who are denied care. This weakened legislation was offered to head off consideration of a stronger version. A patient denied care could sue an HMO in state and federal court but first must exhaust internal and external appeals processes. Passed 226-203. August 2, 2001. A no vote is a +.

V16: HR 2944. Domestic Partner Benefits. Weldon (R-FL) amendment to the FY 2002 District of Columbia Appropriations Bill that would prohibit the use of local, as well as federal, funds to extend city employees' health benefits to unmarried domestic partners. Rejected 194-226. September 25, 2001. A no vote is a +.

V17: HR 2586. U.S. Military Personnel Overseas/Abortions. Sanchez (DCA) amendment to the FY 2002 Defense Authorization Bill which allows female military personnel stationed at U.S. bases overseas to undergo an abortion at medical facilities there provided they pay for it themselves and a doctor consents to perform the operation. Rejected 199-217. September 25, 2001. A yes vote is a +.

V18: HR 2975. Anti-Terrorism Authority. Adoption of the rule to provide for House consideration of the bill that would expand law enforcement's power to investigate suspected terrorists and beef up domestic surveillance. The legislation threatens the civil liberties, civil rights, and due process protections guaranteed individuals in the United States. Adopted 214-208. October 12, 2001. A no vote is a +.

V19: HR 3090. Economic Stimulus. Passage of the Republican version of the post- September 11 economic stimulus package. The bill would grant businesses and individuals $99.5 billion in federal tax cuts in fiscal 2002, and a total of $159.4 billion in reductions over 10 years. Additionally, the bill would allow more individuals to receive tax rebates for 2000, accelerate a reduction of the 27 percent tax bracket to 25 percent, lower the capital gains tax rate from 20 percent to 18 percent and eliminate the corporate alternative minimum tax. Also, the legislation would provide $3 billion to states for health insurance for the unemployed. Passed 216-214. October 24, 2001. A no vote is a +.

V20: HR 3000. Trade Promotion Authority/Fast Track. Passage of the bill to allow expedited negotiation and implementation of trade agreements between the executive branch and foreign countries. The bill includes provisions requiring increased consultations with Congress on any proposed changes of tariffs for imports of sensitive agriculture products and on trade disparities for textile products. Passed 215-214. December 6, 2001. A no is a +.

References

Ada (2002). 2001 Voting Record: Shattered Promise of Liberal Progress. ADA Today, 57(1), 1-17.

Examples

data(house)
   house

Utility function for Gifi knot specifications.

Description

Produces a list of knots used as input argument in various Gifi functions (homals, princals, morals, etc.). Contains options for placing knots at the quantiles, for knots equally spaced on the range, for knots at the data points, and for no interior knots.

Usage

knotsGifi(x, type = c("Q", "R", "E", "D"), n = 3)

Arguments

x

Data frame

type

"Q" for knots at the quantiles, "R" for equally spaced knots, "E" for no interior knots, "D" for knots at the data points

n

Number of interior knots (ignored for type = "E" and type = "D")

Details

Simple linear or polynomial transformations can be specified using type = "E" and the corresponding degree in the subsequent Gifi function call. If the data frame contains factors, they are converted internally to numeric using makeNumeric.

Value

A list containing knots for each variable.

Examples

ABC6 <- ABC[,6:11]
knotsGifi(ABC6, "Q")      ## tercile knots
knotsGifi(ABC6, "Q", 4)   ## quartile knots
knotsGifi(ABC6, "R")      ## 3 equally spaced interior knots
knotsGifi(ABC6, "E")      ## no interior knots
knotsGifi(ABC6, "D")      ## knots at the data points

Convert a data frame into a numeric matrix.

Description

Utility function for converting a data frame with factors (numeric and character levels), ordered factors, and numerical variables into a numeric matrix.

Usage

makeNumeric(x)

Arguments

x

Data frame

Value

A numeric matrix.

Examples

makeNumeric(ABC[,6:11])

Mammals dataset

Description

Dentition of mammals.

Usage

mammals

Format

A data frame with the tooth pattern, the number of top incisors, bottom incisors, top canines, bottom canines, top premolars, bottom premolars, top molars, and bottom molars.

- top incisors: (1) zero incisors; (2) one incisor; (3) two incisors; (4) three or more incisors.

- bottom incisors: (1) zero incisors; (2) one incisor; (3) two incisors; (4) three incisors; (5) four incisors.

- top canine: (1) zero canines; (2) one canine.

- bottom canine: (1) zero canines; (2) one canine.

- top premolar (1) zero premolars; (2) one premolar; (3) two premolars; (3) two premolars; (4) three premolars; (5) four premolars.

- bottom premolar: (1) zero premolars; (2) one premolar; (3) two premolars; (3) two premolars; (4) three premolars; (5) four premolars.

- top molar: (1) zero, one or two molars; (2) more than two molars.

- bottom molar: (1) zero, one or two molars; (2) more than two molars.

References

Hartigan, J.A. (1975). Clustering Algorithms. New York: Wiley.

Examples

data(mammals)
   mammals

Multiple Regression (MORALS).

Description

Fits multiple regression within the Gifi framework.

Usage

morals(x, y, xknots = knotsGifi(x, "Q"), yknots = knotsGifi(y, "Q"), xdegrees = 2, 
ydegrees = 2, xordinal = TRUE, yordinal = TRUE, xties = "s", yties = "s", xmissing = "m", 
ymissing = "m", xactive = TRUE, xcopies = 1, itmax = 1000, eps = 1e-6, verbose = FALSE)

Arguments

x

Vector or data frame with predictor variables (all numeric)

y

Vector with response variable

xknots

Knots specification for predictors (see knotsGifi)

yknots

Knots specification for response (see knotsGifi)

xdegrees

Degree specification for predictors

ydegrees

Degree specification for response

xordinal

Whether predictors should be considered as ordinal or not. Alternatively, one can specify a boolean vector of length m denoting which variables should be ordinally restricted or not

yordinal

Whether response should be considered as ordinal or not

xties

How predictor ties should be handled: primary ("p"), secondary ("s"), or tertiary ("t")

yties

How response ties should be handled: primary ("p"), secondary ("s"), or tertiary ("t")

xmissing

How missing predictor values should be handled: multiple ("m"), single ("s"), or average ("a")

ymissing

How missing response values should be handled: multiple ("m"), single ("s"), or average ("a")

xactive

Which predictors should be active or inactive

xcopies

Number of copies for each predictor

itmax

Maximum number of iterations

eps

Convergence criterion

verbose

Iteration printout

Details

Fits MORALS as described in De Leeuw et al. (2017).

Value

rhat

Induced correlation matrix

objectscores

Object scores (rows)

xhat

Optimally transformed predictors

yhat

Optimally transformed response

ypred

Predicted (fitted) values

yres

Residuals

smc

Squared multiple correlation

ntel

Number of iterations

f

Loss function value

References

Gifi, A. (1990). Nonlinear Multivariate Analysis. New York: Wiley.

De Leeuw, J., Mair, P., Groenen, P. J. F. (2017). Multivariate Analysis with Optimal Scaling.

See Also

homals, princals, plot.morals

Examples

x <- scale(as.matrix(seq(0, pi, length = 20)), scale = FALSE)
y <- scale(as.matrix(sin(x)), scale = FALSE)
fitxy <- morals(x, y, xknots = knotsGifi(x, "E"), xdegrees = 2)
plot(fitxy, main = c("x", "y"))
plot(fitxy, plot.type = "resplot")

plot(fitxy$xhat, fitxy$yhat)
lines(fitxy$xhat, fitxy$ypred)

plot(x, fitxy$yhat)
lines(x, fitxy$ypred)

Neumann dataset

Description

Willard Gibbs discovered a theoretical formula connecting the density, the pressure, and the absolute temperature of a mixture of gases with convertible components. He applied this formula and the estimated constants to 65 experiments of Neumann, and he discusses the systematic and accidental divergences (residuals).

Usage

neumann

Format

A data frame with temperature, pressure, and density on 65 experiments.

References

Gifi, A. (1990). Nonlinear multivariate analysis. New York: Wiley. Wilson, E.B. (1926). Empiricism and rationalism. Science, 64, 47-57

Examples

data(neumann)
   neumann

Plot Methods for Homals

Description

Various plotting options for objects of class "homals".

Usage

## S3 method for class 'homals'
plot(x, plot.type = "jointplot", plot.dim = c(1, 2), 
var.subset = "all", col.points = rainbow_hcl(ncol(x$data)), col.scores = "gray", 
col.lines = 1:x$ndim, cex.scores = 0.8, cex.loadings = 0.8, labels.scores = FALSE, 
stepvec = NA, max.plot.array = NA, asp = 1, main, xlab, ylab, xlim, ylim, ...)

Arguments

x

Object of class "homals"

plot.dim

Vector with dimensions to be plotted.

plot.type

String indicating which type of plot to be produced: "jointplot", "biplot", "screeplot", "transplot". See details.

var.subset

Numeric vector for subsetting variables to be plotted. If missing, all variables are taken into account

col.points

Color categories.

col.scores

Color object scores.

col.lines

Line colors for transformation and scree plot.

cex.scores

Size object scores.

cex.loadings

Size loading labels.

asp

Aspect ratio

labels.scores

Whether object score labels should be plotted.

stepvec

Vector whether step function should be plotted (see details).

max.plot.array

Number of panels in transformation plot.

main

Plot title.

type

Type of points/lines to be plotted.

xlab

Label of x-axis.

ylab

Label of y-axis.

xlim

Limits for x-axis.

ylim

Limits for y-axis.

...

Further plot arguments passed: see plot

Details

Plot description:

- Biplot (plot.type = "biplot"): Biplot with the object scores and the category quantifications.

- Transformation plot (plot.type = "transplot"): Plots the original scale against the transformed scale (first dimension) for each variable separately.

- Joint plot (plot.type = "jointplot"): Plots the category quantifications.

- Scree plot (plot.type = "screeplot"): Produces a scree plot based on the eigenvalues.

For transformation plots only: If stepvec = NA, the function tries to figure out which variable should be plotted as step function. Alternatively, a boolean vector (with length number of variables) can be specified (TRUE step function, FALSE smooth function).

Examples

fithart <- homals(hartigan, ndim = 3, normobj.z = FALSE)
fithart

plot(fithart)   
plot(fithart, var.subset = c(1,2,4), plot.dim = c(2,3))
plot(fithart, plot.type = "biplot", col.scores = "black")
plot(fithart, plot.type = "biplot", col.scores = "black", labels.scores = TRUE, col.points = 1:6)
plot(fithart, plot.type = "screeplot", col.lines = "red")
plot(fithart, plot.type = "transplot", plot.dim = 1:3, col.lines = c(1, 2, 4))
plot(fithart, plot.type = "transplot", stepvec = rep(FALSE, 6), max.plot.array = c(2,2))

Plot Methods for Morals

Description

Various plotting options for objects of class "morals".

Usage

## S3 method for class 'morals'
plot(x, plot.type = "transplot", var.subset = "all", col.lines = "black", 
stepvec = NA, max.plot.array = c(2, 2), main, xlab, ylab, xlim, ylim, ...)

Arguments

x

Object of class "morals"

plot.type

String indicating which type of plot to be produced: "resplot", "transplot"

var.subset

Numeric vector for subsetting variables to be plotted. If missing, all variables are taken into account. Ignored for non separate variable plots.

col.lines

Line colors for transformation

stepvec

Vector whether step function should be plotted

max.plot.array

Number of panels in transformation plot.

main

Plot title.

type

Type of points/lines to be plotted.

xlab

Label of x-axis.

ylab

Label of y-axis.

xlim

Limits for x-axis.

ylim

Limits for y-axis.

...

Further plot arguments passed: see plot

Details

Plot description: The transformation plot (plot.type = "transplot"): Plots the original scale against the transformed scale for each variable separately.

Examples

x <- scale(as.matrix(seq(0, pi, length = 20)), scale = FALSE)
y <- scale(as.matrix(sin(x)), scale = FALSE)
fitxy <- morals(x, y, xknots = knotsGifi(x, "E"), xdegrees = 2)
plot(fitxy, main = c("x", "y"))
plot(fitxy, plot.type = "resplot")

Plot Methods for Princals

Description

Various plotting options for objects of class "princals".

Usage

## S3 method for class 'princals'
plot(x, plot.type = "loadplot", plot.dim = c(1, 2), var.subset = "all", 
col.scores = "black", col.loadings = "black", col.lines = "black", cex.scores = 0.8, 
cex.loadings = 0.8, stepvec = NA, max.plot.array = NA, expand = 1, 
asp = 1, main, xlab, ylab, xlim, ylim, ...)

Arguments

x

Object of class "princals"

plot.type

String indicating which type of plot to be produced: "biplot", "loadplot", "screeplot", "transplot". See details.

plot.dim

Vector with dimensions to be plotted.

var.subset

Numeric vector for subsetting variables to be plotted. If missing, all variables are taken into account. Ignored for non separate variable plots.

col.scores

Color object scores.

col.loadings

Color loading vectors.

col.lines

Line colors for transformation and scree plot.

cex.scores

Size object scores.

cex.loadings

Size loading labels.

asp

Aspect ratio

stepvec

Vector whether step function should be plotted (see details).

max.plot.array

Number of panels in transformation plot.

expand

Expansion factor for loadings in biplot.

main

Plot title.

type

Type of points/lines to be plotted.

xlab

Label of x-axis.

ylab

Label of y-axis.

xlim

Limits for x-axis.

ylim

Limits for y-axis.

...

Further plot arguments passed: see plot

Details

Plot description:

- Biplot (plot.type = "biplot"): Biplot with the object scores and the loadings. It uses biplot.default from stats internally (see corresponding help file for additional arguments)

- Transformation plot (plot.type = "transplot"): Plots the original scale against the transformed scale (first dimension) for each variable separately.

- Loadings plot (plot.type = "loadplot"): Plots the loadings of the variables and connects them with the origin.

- Scree plot (plot.type = "screeplot"): Produces a scree plot based on the eigenvalues.

For transformation plots only: If stepvec = NA, the function tries to figure out which variable should be plotted as step function. Alternatively, a boolean vector (with length number of variables) can be specified (TRUE step function, FALSE smooth function).

Examples

ABC6 <- ABC[,6:11]
fitord <- princals(ABC6, ndim = 3)  ## 3D princals solution

## transformation plot
plot(fitord, plot.type = "transplot", var.subset = 1:4, lwd = 2, col.lines = "coral")

## loadings plot
plot(fitord, "loadplot", main = "Loadings Plot ABC Data")

## biplot
plot(fitord, "biplot", main = "Biplot ABC Data", cex.scores = 0.5)  
plot(fitord, "biplot", main = "Biplot ABC Data")
plot(fitord, "biplot", main = "Biplot ABC Data", plot.dim = c(2,3))

## scree plot
plot(fitord, "screeplot")

Categorical principal component analysis (PRINCALS).

Description

Fits a categorical PCA. The default is to take each input variable as ordinal but it works for mixed scale levels (incl. nominal) as well. Through a proper spline specification various continuous transformation functions can be specified: linear, polynomials, and (monotone) splines.

Usage

princals(data, ndim = 2, levels = "ordinal", ordinal, knots, ties = "s", 
degrees = 1, copies = 1, missing = "s", normobj.z = TRUE, active = TRUE,
itmax = 1000, eps = 1e-06, verbose = FALSE)

Arguments

data

Input data frame: n observations, m variables

ndim

Number of dimensions to be computed

levels

A vector of length m denoting basic scale levels ("nominal", "ordinal", "metric"; see details

ordinal

If knots are specified manually, a boolean vector of length m denotes which variables should be ordinally restricted or not (see details)

knots

Scale levels can be specified manually using splines (see knotsGifi). If knots is set, this overrides level (see details)

ties

How ties should be handled: primary ("p"), secondary ("s"), or tertiary ("t")

degrees

Spline degrees. If different degrees should be used across variables, a vector of length m can be specified.

copies

Number of copies for each variables (also as vector of length m)

missing

How missing values should be handled: multiple ("m"), single ("s"), or average ("a")

active

Which variables should be active or inactive (also as vector of length m)

normobj.z

If TRUE, object scores are z-scores, if FALSE, they are restriction to SS of 1.

itmax

Maximum number of iterations

eps

Convergence criterion

verbose

Iteration printout

Details

The measurement (or scale) levels of the variables are incorporated via spline transformations. If the user only needs simple scale levels like nominal, ordinal, and metric, a corresponding vector can be specified in the levels argument without setting knots and ordinal. The corresponding spline transformations (unrestricted, monotone, and linear) are then created internally. If all scale level transformations are the same, ordinal can be a single value. For more advanced transformations such as polynomial or more flexible splines, the knots and ordinal arguments need to be specified instead of levels.

Value

transform

Optimally transformed scores

rhat

Induced correlation matrix

evals

Eigenvalues of induced correlation matrix

objectscores

Object scores (rows)

scoremat

Optimally scaled data matrix (first dimension)

quantifications

Category quantifications

dmeasures

Discimination matrices

lambda

Average discrimination matrix

weights

Component weights

loadings

Component loadings

ntel

Number of iterations

f

Loss function value

data

Original data frame

datanum

Numerical data frame

ndim

Number of extracted dimensions

call

Function call

References

Gifi, A. (1990). Nonlinear Multivariate Analysis. New York: Wiley.

De Leeuw, J., Mair, P., Groenen, P. J. F. (2017). Multivariate Analysis with Optimal Scaling.

See Also

homals, plot.princals

Examples

ABC6 <- ABC[,6:11]

## ordinal PCA
fitord <- princals(ABC6)  ## ordinal PCA
fitord
summary(fitord)

plot(fitord, plot.type = "transplot")
plot(fitord, "loadplot", main = "Loadings Plot ABC Data")  ## aspect ratio = 1
plot(fitord, "biplot", main = "Biplot ABC Data")
plot(fitord, "screeplot")

## linear restrictions (mimics standard PCA)
abc_knots <- knotsGifi(ABC6, "E")     ## 0 interior knots
fitlin <- princals(ABC6, knots = abc_knots, ordinal = TRUE)  
fitlin 
fitlin$evals
plot(fitlin, plot.type = "transplot")

## compare with standard PCA
ABCnum <- makeNumeric(ABC6)
fitpca <- prcomp(ABCnum, scale = TRUE)
fitpca$sdev^2   

## more complicated specifications
## Not run: 
data(epi.bfi, package = "psychTools")
epi6 <- epi.bfi[,1:6]
fitepi1 <- princals(epi6, knots = knotsGifi(epi6, "Q"))    ## monotone splines (degree 2)
fitepi1
plot(fitepi1, "transplot")

## no interior knots vars 1 and 2; data knots vars 3 and 4; 5 
## interior percentile knots var 5; no interior knots var 6)
knotList <- c(knotsGifi(epi6[,1:2], "E"), 
              knotsGifi(epi6[,3:4], "D"), 
              knotsGifi(epi6[,5], "Q", n = 5),
              knotsGifi(epi6[,6], "E"))
knotList  
ordvec <- c(TRUE, FALSE, TRUE, FALSE, FALSE, TRUE) ## ordinal restrictions
degvec <- c(3, -1, 2, 2, 3, 1)                     ## spline degrees (second variable nominal)
fitepi2 <- princals(epi6, knots = knotList, ordinal = ordvec, degrees = degvec)
fitepi2
plot(fitepi2, "transplot")

## End(Not run)

Roskam dataset

Description

The Department of Psychology at the University of Nijmegen had 9 different areas of research and teaching. Each of the 39 psychologists working in the department ranked all 9 areas in order of relevance for their work.

Usage

roskam

Format

A data frame with the following 9 areas:

SOC: Social Psychology

EDU: Educational and Developmental Psychology

CLI: Clinical Psychology

MAT: Mathematical Psychology and Psychological Statistics

EXP: Experimental Psychology

CUL: Cultural Psychology and Psychology of Religion

IND: Industrial Psychology

TST: Test Construction and Validation

PHY: Physiological and Animal Psychology

References

Roskam, E (1968). Metric Analysis of Ordinal Data in Psychology. PhD thesis, University of Leiden.

Examples

data(roskam)
   roskam

Senate votes 2007

Description

2007 senate votes on 20 issues selected by Americans for Democratic Action. The votes selected cover a full spectrum of domestic, foreign, economic, military, environmental and social issues. We tried to select votes which display sharp liberal/conservative contrasts and coded them accordingly. In many instances we have chosen procedural votes: amendments, motions to table, or votes on rules for debate. Often these votes reveal true attitudes frequently obscured in the final votes.

Usage

senate07

Format

A data frame (98 senators) with the following variables:

Party: R = Republican, D = Democrat, I = Independent.

I1. S 1. Ethics and Lobbying Overhaul: Grass-Roots Lobbying Bennett (R-UT) amendment to Reid (D-NV) ethics reform legislation. Reid's legislation would overhaul Congressional lobbying and ethics rules for Senators and their staffs, restrict use of more broadly defi ned earmarks, prohibit Senators and staff from accepting gifts and free meals, extend the period before former Senators can become lobbyists, prohibit lobbyist-funded travel, and require trips funded by private entities to be vetted by the Select Ethics Committee. The Bennett amendment, permitting the travel of Members of Congress hosted by 501 (c) (3), or 'grass-roots lobbying' organizations, was adopted 51-46. Jan. 17, 2007. A no vote is a 1.

I2. HR 2. Minimum Wage Increase: Motion to invoke cloture (thus limiting debate) on a Baucus (D-MT) substitute amendment to raise the minimum wage to $7.25 per hour over two years and provide $8.3 billion in small-business tax incentives. The tax provisions would be offset with revenue increases, including a $1 million cap on the amount of executive compensation that can be tax-deferred in any year and extend certain restrictions on certain sale-in-leaseout deals. (Three-fifths of the total Senate, 60 votes, is required to invoke cloture.) Motion agreed to 87-10. Jan 30, 2007. A yes vote is a 1.

I3. S 574. Iraq War 'Surge': Motion to invoke cloture and proceed to a bill that would express the sense of Congress in support of U.S. military serving in Iraq, while disapproving of President Bush's 'surge' decision to deploy more than 20000 additional U.S. combat troops to that country and requiring the President to submit a report to Congress every 30 days on military progress in Iraq. Motion rejected 56-34. Feb. 17, 2007. A yes vote is a 1.

I4. S J Res 9. Iraq Mission: Passage of a joint resolution to limit the mission of U.S. forces in Iraq, within 120 days of enactment, to counter-terrorism efforts, training Iraqi forces and protecting U.S. assets. It would set a binding goal of withdrawing most combat troops by March 31, 2008. (By unanimous consent, the Senate agreed to require 60 votes to pass the joint resolution.) Rejected 48-50. March 15, 2007. A yes vote is a 1.

I5. S 3. Medicare Prescription Drug Price Negotiation: Motion to invoke cloture and proceed to a bill allowing the Health and Human Services Department to negotiate the prices drug companies charge under the Medicare Part D prescription drug program. Motion rejected 55-42. April 18, 2007. A yes vote is a 1.

I6. HR 1495. Water Resources Development Act Reauthorization - Climate Change: Kerry (D-MA) amendment to Boxer (D-CA) legislation authorizing about $14 billion for Army Corps of Engineers water resources development projects, including initiatives for storm protection in Louisiana, fl ood control, and ecosystem restoration. The Kerry amendment would require the Army Corps of Engineers to include the impact on global climate change in any relevant study of water resource projects.(By unanimous consent, the Senate agreed to require 60 votes to adopt the amendment.) Rejected 51-42. May 15, 2007. A yes vote is a 1.

I7. S 1348. Immigration Overhaul: Motion to invoke cloture on Kennedy (D-MA) legislation to overhaul U.S. immigration policies and institute new border security measures, including an electronic verification system. It would allocate some green cards on a 'merit-based' system based on certain criteria, including a highdemand occupation, profi ciency in English, and higher education degrees. Half of the green cards would be allocated based on family relations. It also would provide for a temporary guest worker program that would allow workers to remain in the United States for up to six years, provided that they return to their home country for a year after every two years they remain in the United States. A 'yea' was a vote in support of Kennedy's and the President's position. Motion rejected 45-50. June 7, 2007. A yes vote is a 1.

I8. HR 800. EFCA: Motion to invoke cloture on the Reid (D-NV) motion to proceed to a bill that would allow union organizers to bypass an NLRB-sponsored election if a majority of eligible employees sign a petition in support of a union. Motion rejected 51-48. June 26, 2007. A yes vote is a 1.

I9. HR 1585. Fiscal 2008 Defense Authorization: Motion to invoke cloture on a Levin (D-MI) amendment mandating a drawdown and redeployment of U.S. forces in Iraq by the end of April 2008, except to protect U.S. personnel, train Iraqi security forces, and conduct counter terrorism operations against al Qaeda and other international terrorist organizations. Redeployment would begin within 120 days of enactment. The bill would authorize $648.3 billion for defense programs in fiscal 2008, including $127.5 billion for the wars in Iraq and Afghanistan. It also would authorize $143.5 billion for operations and maintenance; $109.9 billion for procurement; $122.9 billion for military personnel, and $74.7 billion for research, development, testing and evaluation. Motion rejected 52-47. July 18, 2007. A yes vote is a 1.

I10. S 2011. FISA: Passage of a bill to amend the Foreign Intelligence Surveillance Act of 1978 (FISA) to expand the authority of the Attorney General and the Director of National Intelligence to conduct surveillance of communication between one suspected foreign terrorist and another without a court warrant. Communications companies would be compelled to comply with the government's conduct of such surveillance. Within 10 days of initiating the electronic surveillance, the Administration would be required to describe to the FISA court the procedures they used to determine whether the intelligence acquisition being conducted without a warrant is directed at foreign targets overseas. The FISA court would then rule on the procedures. The bill would sunset after six months. (By unanimous consent, the Senate agreed to require 60 votes to pass the bill.) Rejected 43-45. Aug. 3, 2007. A yes vote is a 1.

I11. S 1257. District of Columbia Voting Rights Motion to invoke cloture on a Reid (D-NV) motion to proceed to a bill to increase the membership of the House of Representatives to 437, by granting a seat to the District of Columbia and an additional seat to Utah. Motion rejected 57-42. Sept. 19, 2007. A yes vote is a 1.

I12.HR 1585. Fiscal 2008 Defense Authorization: Motion to invoke cloture on the Kennedy (D-MA) amendment to Levin (D-MI) legislation (see vote No. 9, above). The Kennedy amendment would make violent crimes that cause bodily harm based on the victim's race, color, religion or national origin punishable by a fi ne and up to 10 years in prison, and punishable by a life sentence if the victim dies, is kidnapped or subjected to aggravated sexual abuse. It also would create the same penalties for crimes motivated by gender, sexual orientation, gender identity, or disability. (Subsequently, the Kennedy amendment was adopted by voice vote.) Motion agreed to 60-39. Sept. 2007. A yes vote is a 1.

I13. HR 976. SCHIP: Motion to invoke cloture on the Reid (D-NV) motion to agree to the House bill reauthorizing the State Children's Health Insurance Program (SCHIP) at nearly $60 billion over five years, expanding the program by $35 billion. To offset the cost of the expansion, the bill would increase the tax on cigarettes by 61 cents to $1 per pack and raise taxes on other tobacco products. Motion agreed to 69-30. Sept. 27, 2007. A yes vote is a 1.

I14. HR 3043. Fiscal 2008 Labor - HHS-Education Appropriations - Limiting Abortion Funding: Vitter (R-LA) amendment to Harkin (D-IA) legislation. The Vitter amendment would prohibit the distribution of Title X family planning funds to abortion providers except when a woman suffers from a physical disorder, injury, or illness that would risk the life of the mother unless an abortion is provided. The amendment would not apply to hospitals. Harkin's legislation would appropriate $605.5 billion in fiscal 2008, including $149.9 billion in discretionary spending, for the departments of Labor, Health and Human Services (HHS), and Education, and for related agencies. It would provide $63 billion for the Education Department, $14.9 billion for the Labor Department and $479.1 billion for HHS. Rejected 41-52. Oct. 18, 2007. A no vote is a 1.

I15. Southwick Nomination: Motion to invoke cloture on the nomination of Leslie Southwick of Mississippi to be a judge for the 5th Circuit Court of Appeals. Opponents argued that, in his positions related to African Americans, workers, gays, and women, Mr. Southwick was unsuited to a lifetime appointment to the federal judiciary. Motion agreed to 62-35. Oct. 24, 2007. A no vote is a 1.

I16. HR 1495. Water Resources Development - Veto Override: Passage, over President Bush's Nov. 2, 2007, veto, of a bill authorizing $23.2 billion for more than 900 water resource development projects and studies by the Army Corps of Engineers for flood control, navigation, beach erosion control, and environmental restoration. The bill would require independent peer review for certain projects that exceed $40 million. It would authorize $3.9 billion for a system of new locks and dams and environmental restoration for the Upper Mississippi River and Illinois waterway system. It also would authorize hurricane recovery activities along the Gulf Coast. (A two-thirds majority of those present and voting of both chambers - 62 senators in this instance - is required to override a veto.) Passed, thus enacted into law, 79-14. Nov. 8, 2007. A yes vote is a 1.

I17.HR 3688. U.S.-Peru Trade Agreement: Passage of a bill that would implement a NAFTA/CAFTA model trade agreement between the United States and Peru. The agreement would reduce most tariffs and duties currently affecting trade between the two countries, increase protections for intellectual property and would require Peru to take steps to strengthen its labor and environmental-enforcement standards. Passed, thus cleared for the President, 77-18. Dec. 4, 2007. A no vote is a 1.

I18. HR 3996. AMT Adjustment: Motion to invoke cloture on a Reid (D-NV) motion to proceed to the bill that would provide a one-year adjustment to the alternative minimum tax (AMT) on 2007 income, exempt an additional 21 million taxpayers from paying the AMT, extend several expiring tax provisions for one year, and expand eligibility in 2008 for the refundable child tax credit. To offset the cost, the bill includes revenue raisers, such as increasing the tax on the carried interest of private equity managers, venture capitalists and some real estate investors. Motion rejected 46-48. Dec. 6, 2007. A yes vote is a 1.

I19. HR 6. Energy Policy: Motion to invoke cloture on the Reid (D-NV) motion to concur in the House bill with an additional amendment to require new Corporate Average Fuel Economy standards of 35 miles per gallon for cars and light trucks, and require the production and use of 36 billion gallons of biofuels by 2022. It would direct the Energy Department to set new energy efficiency standards. The additional amendment would strike a provision requiring utilities to produce 15 percent of their electricity from alternative sources by 2020. It also would increase to $21.8 billion a package of tax incentives that would be offset in part by eliminating or reducing $13 billion in subsidies for major oil and gas companies. Motion rejected 59-40. Dec. 13, 2007. A yes vote is a 1.

I20. HR 2419. Farm Bill Reauthorization Passage of a bill to authorize $286 billion from fiscal 2008 through fiscal 2012 for federal farm, nutrition assistance, rural development, and agricultural trade programs. Producers would not be eligible if the average of their three-year adjusted gross income is more than $1 million in 2009, and more than $750,000 in 2010 and subsequent years, unless at least two-thirds of that income is derived from agriculture. The bill also would limit the amount that farms could receive during any crop year under specific programs to $40,000 for direct and fi xed payments, and $60,000 for counter-cyclical and average crop revenue payments. It would create a new optional subsidy called the Average Crop Revenue program, which would tie payments to state based farm revenue figures. Country-of-origin labels for all meat would be required by September 2008. The bill would extend the Milk Income Loss Contract program through fiscal 2012. It would increase, from $134 to $140 per month, the amount households could deduct from gross income in determining their level of food stamp benefits. It also would authorize $1.1 billion to promote farm-based renewable energy and effi ciency. (Before passage, the Senate adopted a Harkin (D-IA) substitute amendment by voice vote.) Passed 79-14. Dec. 14, 2007. A yes vote is a 1.

Examples

data(senate07)
   senate07

Sleeping Bags

Description

This data set provides 4 variables measured on 21 sleeping bags. The variables are temperature, weight, price, and material.

Usage

sleeping

Format

A data frame of dimenson 21 times 4.

References

Prediger, S. (1997). Symbolic objects in formal concept analysis. In G. Mineau, and A. Fall (eds.), Proceedings of the 2nd International Symposium on Knowledge, Retrieval, Use, and Storage for Efficiency.

Examples

data(sleeping)
   sleeping

Small dataset

Description

A small artifical dataset.

Usage

small

Format

A data frame with 3 variables each of them has 3 categories.

References

Gifi, A. (1990). Nonlinear Multivariate Analysis: Wiley.

Examples

data(small)
   small