addLink: Add a New Link Between Two Variables in a LVM

addLinkR Documentation

Add a New Link Between Two Variables in a LVM

Description

Generic interface to add links to lvm objects.

Usage

addLink(object, ...)

## S3 method for class 'lvm'
addLink(
  object,
  var1,
  var2,
  covariance,
  all.vars = lava::vars(object),
  warnings = FALSE,
  ...
)

## S3 method for class 'lvm.reduced'
addLink(object, ...)

Arguments

object

a lvm object.

...

[internal] only used by the generic method and from addLink.lvm.reduced to addLink.lvm.

var1

[character or formula] the exogenous variable of the new link or a formula describing the link to be added to the lvm.

var2

[character] the endogenous variable of the new link. Disregarded if the argument var1 is a formula.

covariance

[logical] is the link is bidirectional? Ignored if one of the variables non-stochastic (e.g. exogenous variables).

all.vars

[internal] a character vector containing all the variables of the lvm object.

warnings

[logical] Should a warning be displayed when no link is added?

Details

The argument all.vars is useful for lvm.reduce object where the command vars(object) does not return all variables. The command vars(object, xlp = TRUE) must be used instead.

Arguments var1 and var2 are passed to initVarlink.

Examples

library(lava)
set.seed(10)

m <- lvm()
regression(m) <- c(y1,y2,y3)~u
regression(m) <- u~x1+x2
latent(m) <- ~u
m2 <- m

addLink(m, x1 ~ y1, covariance = FALSE)
addLink(m, y1 ~ x1, covariance = FALSE)
coef(addLink(m, y1 ~ y2, covariance = TRUE))

addLink(m2, "x1", "y1", covariance = FALSE)
addLink(m2, "y1", "x1", covariance = FALSE)
newM <- addLink(m, "y1", "y2", covariance = TRUE)
coef(newM)


lavaSearch2 documentation built on April 12, 2023, 12:33 p.m.