Learn R Programming

ggm (version 0.5)

fitDag: Gaussian Markov models specified by a DAG

Description

Fits linear recursive regressions with independent residuals specified by a DAG.

Usage

fitDag(gmat, Syy, n)

Arguments

gmat
a square Boolean matrix representing the edge matrix of the DAG
Syy
a symmetric positive definite matrix, the sample covariance matrix
n
an integer >0, the sample size

Value

  • Athe matrix of the fitted regression coefficients. Each coefficient has the sign reversed.
  • Bthe inverse of matrix B.
  • Deltaa vector containing the partial covariances of each variable given the parents.
  • Shatthe fitted covariance matrix.
  • Khatthe fitted concentration matrix.
  • devthe `deviance' ($-2 \log L$) of the model.
  • dfthe degrees of freedom.

Details

fitDag checks if the order of the nodes in edge matrix is the same of Syy and if not it reorders the edge matrix to match the order of the variables in Syy. The nodes of the edge matrix may form a subset of the variables in Syy.

References

Cox, D. R. & Wermuth, N. (1996). Multivariate dependencies. London: Chapman & Hall.

See Also

DAG, swp.

Examples

Run this code
dag <- DAG(y ~ x+u, x ~ z, z ~ u)
"V" <- structure(c(2.93, -1.7, 0.76, -0.06,
                   -1.7, 1.64, -0.78, 0.1,
                    0.76, -0.78, 1.66, -0.78,
                    -0.06, 0.1, -0.78, 0.81), .Dim = c(4,4),
         .Dimnames = list(c("y", "x", "z", "u"), c("y", "x", "z", "u")))
fitDag(dag, V, 200)

Run the code above in your browser using DataLab