Skip to content

Commit

Permalink
version 1.2-30
Browse files Browse the repository at this point in the history
  • Loading branch information
Claus Dethlefsen authored and gaborcsardi committed Apr 19, 2007
1 parent 7743528 commit 68ed019
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 29 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: deal
Version: 1.2-29
Version: 1.2-30
Date: 2007-04-19
Title: Learning Bayesian Networks with Mixed Variables
Author: Susanne Gammelgaard B�ttcher <alma@math.aau.dk>, Claus Dethlefsen <cld@rn.dk>.
Expand All @@ -9,4 +9,4 @@ Description: Bayesian networks with continuous and/or discrete variables can be
License: GPL version 2 or newer
URL: http://www.math.aau.dk/~dethlef/novo/deal
Collate: addarrows.R autosearch.R conditional.R cycletest.R drawnetwork.R findex.R generic.R genlatex.R heuristic.R inspectprob.R jointcont.R jointdisc.R jointprior.R learning.R makesimprob.R fullsimprob.R maketrylist.R master.R network.R networkfamily.R node.R numbermixed.R perturb.R postc.R postc0.R postdist.R readnet.R rnetwork.R savenet.R unique.R
Packaged: Thu Apr 19 13:31:57 2007; 86c9
Packaged: Fri Apr 20 09:48:30 2007; 86c9
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export("addarrow",
"postcc",
"postdist",
"postdist.node",
"postM",
"print.network",
"print.networkfamily",
"print.node",
Expand Down
44 changes: 22 additions & 22 deletions R/postc.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
## Author : Claus Dethlefsen
## Created On : Tue Mar 12 06:52:02 2002
## Last Modified By: Claus Dethlefsen
## Last Modified On: Thu Jul 24 15:18:29 2003
## Update Count : 143
## Last Modified On: Fri Apr 20 09:25:29 2007
## Update Count : 144
## Status : Unknown, Use with caution!
###############################################################################
##
Expand Down Expand Up @@ -83,32 +83,32 @@ post <- function(mu,tau,rho,phi,y,z,timetrace=FALSE) {
list(mu=mu.n,tau=tau.n,rho=rho.n,phi=phi.n,loglik=loglik)
}

postM <- function(mu,tau,rho,phi,y,z,timetrace=FALSE) {
## Posterior for continuous node with continuous parents
## written as Matrix notation in R (needs Matrix)
if (timetrace) {t1 <- proc.time();cat("[postM ")}
## postM <- function(mu,tau,rho,phi,y,z,timetrace=FALSE) {
## ## Posterior for continuous node with continuous parents
## ## written as Matrix notation in R (needs Matrix)
## if (timetrace) {t1 <- proc.time();cat("[postM ")}

z <- as.Matrix(z)
mu.n <- solve(as.Matrix(tau+t(z)%*%z))%*%(tau%*%mu+t(z)%*%y)
tau.n <- tau + t(z)%*%z
rho.n <- rho + length(y)
phi.n <- phi + t(y - z%*%mu.n)%*%y + t(mu - mu.n)%*%tau%*%mu
## z <- as.Matrix(z)
## mu.n <- solve(as.Matrix(tau+t(z)%*%z))%*%(tau%*%mu+t(z)%*%y)
## tau.n <- tau + t(z)%*%z
## rho.n <- rho + length(y)
## phi.n <- phi + t(y - z%*%mu.n)%*%y + t(mu - mu.n)%*%tau%*%mu


loglik <- 0
s <- as.numeric(phi)/rho*(diag(nrow(z))+ z%*%solve(tau)%*%t(z))
k <- lgamma( (rho + length(y))/2 ) - lgamma(rho/2)-0.5*log(det(rho*s*pi))
ind <- log( 1 + (mahalanobis(y,center=z%*%mu,cov=s,inverted=FALSE))/rho)
loglik <- as.numeric(k) - (rho+length(y))/2 * ind
## loglik <- 0
## s <- as.numeric(phi)/rho*(diag(nrow(z))+ z%*%solve(tau)%*%t(z))
## k <- lgamma( (rho + length(y))/2 ) - lgamma(rho/2)-0.5*log(det(rho*s*pi))
## ind <- log( 1 + (mahalanobis(y,center=z%*%mu,cov=s,inverted=FALSE))/rho)
## loglik <- as.numeric(k) - (rho+length(y))/2 * ind


if (timetrace) {
t2 <- proc.time()
cat((t2-t1)[1],"]")
}
## if (timetrace) {
## t2 <- proc.time()
## cat((t2-t1)[1],"]")
## }

list(mu=mu.n,tau=tau.n,rho=rho.n,phi=phi.n,loglik=loglik)
}
## list(mu=mu.n,tau=tau.n,rho=rho.n,phi=phi.n,loglik=loglik)
## }


postcc <- function(mu,tau,rho,phi,y,z,timetrace=FALSE) {
Expand Down
6 changes: 2 additions & 4 deletions man/deal-internal.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
% Author : Claus Dethlefsen
% Created On : Wed Jan 07 10:32:46 2004
% Last Modified By: Claus Dethlefsen
% Last Modified On: Thu Apr 19 12:54:56 2007
% Update Count : 37
% Last Modified On: Fri Apr 20 09:44:24 2007
% Update Count : 39
% Status : Unknown, Use with caution!
%
\name{deal-internal}
Expand All @@ -16,7 +16,6 @@
\alias{postc}
\alias{postc0c}
\alias{postcc}
\alias{postM}
\alias{learnnode}
\alias{udisclik}
\alias{addrandomarrow}
Expand Down Expand Up @@ -74,7 +73,6 @@
printline(s="-",n=60)

post (mu,tau,rho,phi,y,z,timetrace=FALSE)
postM (mu,tau,rho,phi,y,z,timetrace=FALSE)
postc (mu,tau,rho,phi,y,z,timetrace=FALSE)
postcc (mu,tau,rho,phi,y,z,timetrace=FALSE)
post0 (mu,tau,rho,phi,y,timetrace=FALSE)
Expand Down

0 comments on commit 68ed019

Please sign in to comment.