nipals (version 0.3)

uscrime: U.S. Crime rates per 100,00 people

Description

U.S. Crime rates per 100,00 people for 7 categories in each of the 50 U.S. states in 1977.

Usage

data("uscrime")

Arguments

Format

A data frame with 50 observations on the following 8 variables.

state

U.S. state

murder

murders

rape

rapte

robbery

robbery

assault

assault

burglary

burglary

larceny

larceny

autotheft

automobile thefts

Details

There are two missing values.

References

SAS/STAT User's Guide: High-Performance Procedures. The HPPRINCOMP Procedure. http://support.sas.com/documentation/cdl/en/stathpug/67524/HTML/default/viewer.htm#stathpug_hpprincomp_toc.htm

Examples

Run this code
# NOT RUN {
  library(nipals)
  data(uscrime)

  # SAS deletes rows with missing values
  dat <- uscrime[complete.cases(uscrime), ]
  dat <- as.matrix(dat[ , -1])
  m1 <- nipals(dat) # complete-data method

  # Traditional NIPALS with missing data  
  dat <- uscrime
  dat <- as.matrix(dat[ , -1])
  m2 <- nipals(dat, gramschmidt=FALSE) # missing 
  round(crossprod(m2$loadings),3) # Prin Comps not quite orthogonal
  
  # Gram-Schmidt corrected NIPALS
  m3 <- nipals(dat, gramschmidt=TRUE) # TRUE is default
  round(crossprod(m3$loadings),3) # Prin Comps are orthogonal
# }

Run the code above in your browser using DataLab