findNewLink: Find all New Links Between Variables

findNewLinkR Documentation

Find all New Links Between Variables

Description

Find all new links between variables (adapted from lava::modelsearch).

Usage

findNewLink(object, ...)

## S3 method for class 'lvm'
findNewLink(
  object,
  data = NULL,
  type = "both",
  exclude.var = NULL,
  rm.latent_latent = FALSE,
  rm.endo_endo = FALSE,
  rm.latent_endo = FALSE,
  output = "names",
  ...
)

Arguments

object

a lvm object.

...

[internal] only used by the generic method.

data

[optional] a dataset used to identify the categorical variables when not specified in the lvm object.

type

[character vector] the type of links to be considered: "regression", "covariance", or "both", .

exclude.var

[character vector] all links related to these variables will be ignore.

rm.latent_latent

[logical] should the links relating two latent variables be ignored?

rm.endo_endo

[logical] should the links relating two endogenous variables be ignored?

rm.latent_endo

[logical] should the links relating one endogenous variable and one latent variable be ignored?

output

[character] Specify "names" to return the names of the variables to link or specify "index" to return their position.

Value

A list containing:

  • M.links: a matrix with two columns indicating (by name or position) the exogenous and endogenous variable corresponding to each link.

  • links: the name of the additional possible links

  • directional: a logical vector indicating for each link whether the link is unidirectional (TRUE, i.e. regression link) or bidirectional (FALSE, i.e. covariance link).

Examples

library(lava)

m <- lvm()
regression(m) <- c(y1,y2,y3)~u
categorical(m,labels=c("M","F","MF")) <- ~X1
findNewLink(m, rm.endo = FALSE)
findNewLink(m, rm.endo = TRUE)
findNewLink(m, exclude.var = "X1")

regression(m) <- u~x1+x2
latent(m) <- ~u

findNewLink(m, rm.endo = FALSE)
findNewLink(m, rm.endo = TRUE)
findNewLink(m, rm.endo = TRUE, output = "index")
findNewLink(m, type = "covariance")
findNewLink(m, type = "regression")


bozenne/lavaSearch2 documentation built on Feb. 13, 2024, 10:18 p.m.