File: plotseq.npEM.R

package info (click to toggle)
r-cran-mixtools 1.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,828 kB
  • ctags: 20
  • sloc: ansic: 733; makefile: 6
file content (49 lines) | stat: -rwxr-xr-x 1,585 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# plots SEQuence from npEM object
# function for plotting the scalar parameters sequences along iterations
# if object x comes from npEM, just the x$lambda sequence
# if object x comes from spEM, both x$lambda and x$mu sequences
plotseq <- function(x, ...) UseMethod("plotseq") 



plotseq.npEM <- function(x, ...) {
#  ask <- par(ask=TRUE)
  r <- NCOL(x$data)
  n <- NROW(x$data)
  m <- length(x$lambdahat)
  iter <- NROW(x$lambda)
  xlabel <- paste("iterations")
  nbcol <- 1
  if (!is.null(x$symmetric) && x$symmetric)
		nbcol <- 2
	par(mfcol=c(m, nbcol))

# in all cases, plots the lambda's  
  for (j in 1:m) {
  	estim <- paste(round(x$lambdahat[j],3))
  	tt <- substitute(expression(paste("sequence of ",lambda[j],
  			", estimate ",widehat(lambda[j]),"=", estim, sep="")))
  	ylabel <- substitute(expression(paste(lambda[j],sep="")))
  	plot(x$lambda[,j], type="l", main=eval(tt), xlab=xlabel, 
  		ylab=eval(ylabel), ...)
  	lines(c(0,iter),rep(x$lambdahat[j],2),col=2,lty=2)
  	}

## for symmetric location spEM case plots mu
    if (!is.null(x$symmetric) && x$symmetric) {
  	for (j in 1:m) {
  		estim <- paste(round(x$muhat[j],3))
  	  	tt <- substitute(expression(paste("sequence of ",mu[j],
  	  		", estimate ",widehat(mu[j]),"=",estim,sep="")))
  		ylabel <- substitute(expression(paste(mu[j],sep="")))

  	plot(x$mu[,j], type="l", main=eval(tt),  ylab=eval(ylabel),
  			 xlab=xlabel, ...)
  	lines(c(0,iter),rep(x$muhat[j],2),col=2,lty=2)
   		}
#   	legend("topright", legend=round(x$muhat,3), fill=2:(m+1)) 
    } 
#      structure (list (call=match.call()))
}