Skip to contents

Diagnostic plots of fitted 2S-PA model

Usage

tspa_plot(
  tspa_fit,
  title = NULL,
  label_x = NULL,
  label_y = NULL,
  abbreviation = TRUE,
  fscores_type = c("original", "lavaan"),
  ask = FALSE,
  ...
)

Arguments

tspa_fit

An object of class lavaan, representing the output generated from the tspa() function.

title

Character. Set the name of scatter plot. The default value is "Scatterplot".

label_x

Character. Set the name of the x-axis. The default value is "fs_" followed by variable names.

label_y

Character. Set the name of the y-axis. The default value is "fs_" followed by variable names.

abbreviation

Logic input. If FALSE is indicated, the group name will be shown in full. The default setting is TRUE.

fscores_type

Character. Set the type of factor score for input. The default setting is using factor score from observed data (i.e., output from get_fs()). If fscore_type = "est", then it will use output from lavaan::lavPredict().

ask

Logic input. If TRUE is indicated, the user will be asked before before each plot is generated. The default setting is 'False'.

...

Additional arguments passed to plot. See plot for a list.

Value

A scatterplot between factor scores, and a residual plot.

Examples

library(lavaan)
model <- "
# latent variable definitions
ind60 =~ x1 + x2 + x3
dem60 =~ y1 + a*y2 + b*y3 + c*y4
# regressions
dem60 ~ ind60
"
fs_dat_ind60 <- get_fs(
  data = PoliticalDemocracy,
  model = "ind60 =~ x1 + x2 + x3"
)
fs_dat_dem60 <- get_fs(
  data = PoliticalDemocracy,
  model = "dem60 =~ y1 + y2 + y3 + y4"
)
fs_dat <- cbind(fs_dat_ind60, fs_dat_dem60)

tspa_fit <- tspa(
  model = "dem60 ~ ind60",
  data = fs_dat,
  se_fs = list(ind60 = 0.1213615, dem60 = 0.6756472)
)
tspa_plot(tspa_fit)