R/endogenous.R

Defines functions `endogenous` `endogenous.lvmfit` `endogenous.lvm` endogenous.list `endogenous.multigroup`

##' @export
`endogenous` <-
function(x,...) UseMethod("endogenous")

##' @export
`endogenous.lvmfit` <-
function(x,...) {
  endogenous(Model(x),...)
}

##' @export
`endogenous.lvm` <-
function(x,top=FALSE,latent=FALSE,...) {
  observed <- manifest(x)
  if (latent) observed <- vars(x)
  if (top) {
    M <- x$M
    res <- c()
    for (i in observed)
      if (!any(M[i,]==1))
        res <- c(res, i)
    return(res)
  }
  exo <- exogenous(x)
  return(setdiff(observed,exo))
}

##' @export
endogenous.list <- function(x,...) {
  endolist <- c()
  for (i in 1:length(x)) {
    ##    exolist <- c(exolist, exogenous(x[[i]]))
    endolist <- c(endolist, endogenous(x[[i]]))
  }
  endolist <- unique(endolist)
  return(endolist)
##  exolist <- unique(exolist)
##  return(exolist[!(exolist%in%endolist)])
}

##' @export
`endogenous.multigroup` <-
function(x,...) {
  endogenous(Model(x))
}

Try the lava package in your browser

Any scripts or data that you put into this service are public.

lava documentation built on May 2, 2019, 4:49 p.m.