addLink {lavaSearch2} | R 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 |
... |
[internal] only used by the generic method and from |
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 |
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 |
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)