
R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: i386-w64-mingw32/i386 (32-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(norm2)
> 
> ## run EM on fake data with missing values
> set.seed(1234)
> simdata <- data.frame(
+    Y1=rnorm(10), Y2=rnorm(10), Y3=rnorm(10), X1=rnorm(10) )
> simdata$Y3[7] <- simdata$Y2[3]<- NA
> emResult <- emNorm( cbind(Y1,Y2,Y3) ~ X1, data=simdata )
> print( emResult$loglik )
 [1] -6.366297 -4.575648 -4.352761 -4.283800 -4.261342 -4.254066 -4.251727
 [8] -4.250979 -4.250741 -4.250665 -4.250641 -4.250633 -4.250631 -4.250630
[15] -4.250630 -4.250630 -4.250630 -4.250630 -4.250630 -4.250630 -4.250630
> loglik1 <- loglikNorm( emResult )
> emResult2 <- emNorm( emResult )
> loglik2 <- emResult2$loglik[1]
> print( loglik1 == loglik2 )
[1] TRUE
> 
> 
> ## use cholesterol data
> data(cholesterol)
> emResult <- emNorm(cholesterol)
> print( loglikNorm( emResult ) )
[1] -307.9951
> print( loglikNorm( cbind(Y1,Y2,Y3)~1, data=cholesterol, 
+    param=emResult$param ))
[1] -307.9951
> print( loglikNorm( cholesterol, param=emResult$param ))
[1] -307.9951
> print( logpostNorm( emResult ) )
[1] -307.9951
> print( logpostNorm( emResult, prior="uniform" ) )
[1] -307.9951
> print( logpostNorm( emResult, prior="ridge", prior.df=3 ) )
[1] -395.0272
> print( logpostNorm( emResult, prior="invwish", 
+    prior.sscp=diag(c(2,1,2)), prior.df=3 ) )
[1] -383.1954
> 
> 
> proc.time()
   user  system elapsed 
   0.48    0.09    0.54 
