| addLink | R Documentation | 
Generic interface to add links to lvm objects.
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, ...)
| 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? | 
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.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.