Learn R Programming

RSA (version 0.7.1)

RSA: Performs several RSA model tests on a data set with two predictors

Description

Performs several RSA model tests on a data set with two predictors

Usage

RSA(formula, data = NULL, sample.cor = NULL,
    sample.nobs = NULL, center = FALSE, scale = FALSE,
    na.rm = FALSE, out.rm = TRUE, breakline = FALSE,
    models = "default", cubic = FALSE, verbose = TRUE,
    control.variables = c(), ...)

Arguments

formula
A formula in the form z ~ x*y, specifying the variable names used from the data frame, where z is the name of the response variable, and x and y are the names of the predictor variables.
data
A data frame with the variables
sample.cor
A matrix with the sample correlation matrix - you have to provide either raw data in the data argument, or a sample.cor and a sample.nobs
sample.nobs
Number of observations in the sample (goes along with sample.cor)
center
Should predictor variables be centered on the sample mean before analyses?
scale
Should predictor variables be scaled to SD = 1 before analyses?
na.rm
Remove missings before proceeding?
out.rm
Should outliers according to Bollen & Jackman (1980) criteria be excluded from analyses?
breakline
Should the breakline in the unconstrained absolute difference model be allowed (the breakline is possible from the model formulation, but empirically rather unrealistic ...)
verbose
Should additional information during the computation process be printed?
models
A vector with names of all models that should be computed. Should be any from c("absdiff", "absunc", "diff", "additive", "IA", "sqdiff", "RR", "SSD", "SRSD", "full"). For models="all", all models are computed, for models="defaul
cubic
Should a cubic model with the additional terms Y^3, XY^2, YX^2, and X^3 be included?
control.variables
A string vector with variable names from data. These variables are added as linear predictors to the model (in order "to control for them"). No interactions with the other variables are modeled.
...
Additional parameters passed to the lavaan sem function. For example: se="boot"

Details

You can also fit binary outcome variables with a probit link function. For that purpose, the response variable has to be defined as "ordered": r1 <- RSA(Z.binary ~ X*Y, dat, ordered="Z.binary") (for more details see the help file of the /code{sem} function in the lavaan package.). The results can also be plotted with probabilities on the z axis: plot(r1, link="probit", zlim=c(0, 1), zlab="Probability").

See Also

demoRSA, plotRSA, RSA.ST

Examples

Run this code
# Compute response surface from a fake data set
set.seed(0xBEEF)
n <- 300
err <- 15
x <- rnorm(n, 0, 5)
y <- rnorm(n, 0, 5)
df <- data.frame(x, y)
df <- within(df, {
	diff <- x-y
	absdiff <- abs(x-y)
	sqdiff <- (x-y)^2
	z.diff <- diff + rnorm(n, 0, err)
	z.abs <- absdiff + rnorm(n, 0, err)
	z.sq <- sqdiff + rnorm(n, 0, err)
	z.add <- diff + 0.4*x + rnorm(n, 0, err)
	z.complex <- 0.4*x + - 0.2*x*y + + 0.1*x^2 - 0.03*y^2 + rnorm(n, 0, err)
})

r1 <- RSA(z.sq~x*y, df)
print(r1)
compare(r1)
plot(r1)
plot(r1, model="SRSD")
plot(r1, model="full", type="c")
getPar(r1, "coef")	# print model parameters including SE and CI
RSA.ST(r1)	# get surface parameters

# Motive congruency example
data(motcon)
r.m <- RSA(negAct~EM*IM, motcon)

# Get a parameter list of 10 bootstrap samples (usually this should be set to 5000 or higher),
# only from the SSD model
b1 <- bootRSA(r.m, model="SSD", R=10)
# Get a table of percentile confidence intervals and p-values from these bootstrap replications
CI.boot(b1)

# Plot the final model
plot(r.m, model="SSD", xlab="Explicit intimacy motive",
		ylab="Implicit affiliation motive", zlab="Negative activation")

Run the code above in your browser using DataLab