[Depmix-commits] r46 - trunk

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 5 17:15:20 CET 2008


Author: ingmarvisser
Date: 2008-03-05 17:15:20 +0100 (Wed, 05 Mar 2008)
New Revision: 46

Modified:
   trunk/depmix-test3EM2.R
Log:
Example now works with EM on stationary model

Modified: trunk/depmix-test3EM2.R
===================================================================
--- trunk/depmix-test3EM2.R	2008-03-05 16:14:16 UTC (rev 45)
+++ trunk/depmix-test3EM2.R	2008-03-05 16:15:20 UTC (rev 46)
@@ -1,8 +1,9 @@
-setwd("/Users/ivisser/Documents/projects/depmixProject/depmixNew/code/depmix/trunk/")
+setwd("/Users/ivisser/Documents/projects/depmixProject/depmixNew/rforge/depmix/trunk/")
 
 source("depmixS4.R")
 source("classes.R")
 source("hmModel.R")
+source("fithmModel.R")
 source("lystig.R")
 source("fb.R")
 source("trGLM.r")
@@ -13,7 +14,7 @@
 maxit=100
 tol=1e-5
 
-load("speed.Rda")
+load("data/speed.Rda")
 
 rModels <- list(
   list(
@@ -23,13 +24,13 @@
 )
 
 trstart=c(0.8,0.2,0.1,0.9)
-instart=c(.5,.5)
+instart=c(0,1)
 
 
 mod <- depmix(rModels=rModels,data=speed,transition=~1,trstart=trstart,instart=instart)
 
 logLik(mod)
-
+source("EM.R")
 fmod <- em(mod,verbose=T)
 
 # 
@@ -37,28 +38,10 @@
 # 
 
 fixed <- getpars(mod,"fixed")
-allpars <- getpars(mod)
+fixed[2] <- TRUE
+fdmod <- fit(mod,fixed=fixed)
 
-pars <- allpars[!fixed]
 
-logl <- function(pars) {
-	allpars[!fixed] <- pars
-	mod <- setpars(mod,allpars)
-	-logLik(mod)
-}
-
-library(Rdonlp2)
-
-cntrl <- donlp2.control(hessian=FALSE,difftype=1,epsfcn=1e-6)
-
-res1 <- donlp2(pars,logl,control=cntrl)
-
-allpars[!fixed] <- res1$par
-mod <- setpars(mod,allpars)
-
-ll <- logLik(mod)
-
-
 # final loglike
 # [1] -84.3424
 



More information about the depmix-commits mailing list