qqnorm_spss: SPSS like QQ-plot

Description Usage Arguments Value TODO References Examples

Description

The QQ-plot in SPSS and R looks very different. The points points and the QQ-line are positioned differently. qqnorm_spss implements a version of the QQ-plot that resembles the SPSS version. The function returns an object containing the processed data. The output can be plotted using the function plot and ggplot. The parameters that can be passed to the plotting functions are documented in plot.qqnorm.spss and ggplot.qqnorm.spss.

Usage

1
qqnorm_spss(x, standardize = FALSE, method = 1, ties.method = "average")

Arguments

x

A numeric vector.

standardize

Whether the quantiles of the standardized values should be displayed. The default is to display the quantiles using the original data.

method

The method used to assign probabilties for the ranks that are then converted into quantiles. The following methods are implemented (see Castillo-Gutiérrez, Lozano-Aguilera, & Estudillo-Martínez, 2012): 1 = Blom (default), 2 = Rankit / Hazen, 3 = Tukey, 4 = Van der Waerden / Weibull, 5 = Benard and Bos-Levenbach, 6 = Gringorten and 7 = Yu and Huang.

ties.method

Method to assign ranks to ties. One of "average", "first", "random", "max", "min". See ties.method argument from rank for more details.

Value

An list object of class qqnorm.spss with the following elements:

x

The orginal data

y

Corresponding quantiles in original scaling

x.std

Standardized values

y.std

Corresponding quantiles for standardized values

method.name

Name of the method to assign probabilities to ranks

ties.method

Method to treat ties

xname

Name of the variable used to produce the plot

TODO

Check output against SPSS results.

References

Castillo-Gutiérrez, S., Lozano-Aguilera, E., & Estudillo-Martínez, M. D. (2012). Selection of a Plotting Position for a Normal Q-Q Plot. R Script. Journal of Communication and Computer, 9(3), 243–250.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require(ggplot2)

set.seed(0)
x <- sample(0:9, 100, rep=TRUE)

### SPSS like

# Standard QQ-plot
qq <- qqnorm_spss(x, 1)
plot(qq)  
ggplot(qq)

qq <- qqnorm_spss(x, 1, standardize=TRUE)
plot(qq, l.col="red")  
ggplot(qq, line=FALSE)

# Detrended QQ-plot (plottype=2)
plot(qq, plottype=2)  
ggplot(qq, plottype=2)

### R
qqnorm(x, datax=TRUE)
qqline(x, datax=TRUE)

ryouready documentation built on May 1, 2019, 8:39 p.m.