Learn R Programming

faoutlier (version 0.2.2)

obs.resid: Model predicted residual outliers

Description

Compute model predicted residuals for each variable using regression estimated factor scores.

Usage

obs.resid(data, model, na.rm = TRUE, digits = 5)

  ## S3 method for class 'obs.resid':
print(x, ...)

  ## S3 method for class 'obs.resid':
plot(x, y = NULL,
    main = "Observed Residuals", type = c("p", "h"),
    ylab = "obs.resid", ...)

Arguments

data
matrix or data.frame
model
if a single numeric number declares number of factors to extract in exploratory factor ansysis. If class(model) is a sem (or OpenMx model if installed from github) then a confirmatory approach is performed instead
na.rm
logical; remove cases with missing data?
digits
number of digits to round in the final result
x
an object of class obs.resid
...
additional parameters to be passed
y
a NULL value ignored by the plotting function
main
the main title of the plot
ylab
the y label of the plot
type
type of plot to use, default displayes points and lines

See Also

gCD, LD, robustMD

Examples

Run this code
data(holzinger)
data(holzinger.outlier)

#Exploratory
nfact <- 3
(ORresult <- obs.resid(holzinger, nfact))
(ORresult.outlier <- obs.resid(holzinger.outlier, nfact))
plot(ORresult)
plot(ORresult.outlier)

#Confirmatory with sem
model <- specifyModel()
	  F1 -> V1,    lam11
	  F1 -> V2,    lam21
	  F1 -> V3,    lam31
	  F2 -> V4,    lam41
	  F2 -> V5,    lam52
	  F2 -> V6,    lam62
	  F3 -> V7,    lam73
	  F3 -> V8,    lam83
	  F3 -> V9,    lam93
	  F1 <-> F1,   NA,     1
	  F2 <-> F2,   NA,     1
	  F3 <-> F3,   NA,     1

(ORresult <- obs.resid(holzinger, model))
(ORresult.outlier <- obs.resid(holzinger.outlier, model))
plot(ORresult)
plot(ORresult.outlier)

#Confirmatory using OpenMx (requires github version, see ?faoutlier)
manifests <- colnames(holzinger)
latents <- c("F1","F2","F3")
#specify model, mxData not necessary but useful to check if mxRun works
model <- mxModel("Three Factor",
      type="RAM",
      manifestVars = manifests,
      latentVars = latents,
      mxPath(from="F1", to=manifests[1:3]),
	     mxPath(from="F2", to=manifests[4:6]),
	     mxPath(from="F3", to=manifests[7:9]),
      mxPath(from=manifests, arrows=2),
      mxPath(from=latents, arrows=2,
            free=FALSE, values=1.0),
      mxData(cov(holzinger), type="cov", numObs=nrow(holzinger))
	  )

(ORresult <- obs.resid(holzinger, model))
(ORresult.outlier <- obs.resid(holzinger.outlier, model))
plot(ORresult)
plot(ORresult.outlier)

Run the code above in your browser using DataLab