diff --git a/R/map-quap-class.r b/R/map-quap-class.r index f05525a..3b0b1de 100644 --- a/R/map-quap-class.r +++ b/R/map-quap-class.r @@ -95,7 +95,11 @@ function( object , n=10000 , clean=TRUE , ... ) { } else { mu <- xcoef(object) } - result <- as.data.frame( mvrnorm( n=n , mu=mu , Sigma=vcov(object) ) ) + if ( n==1 ) { + result <- as.data.frame( t( mvrnorm( n=n , mu=mu , Sigma=vcov(object) ) ) ) + } else { + result <- as.data.frame( mvrnorm( n=n , mu=mu , Sigma=vcov(object) ) ) + } if ( clean==TRUE ) { # convert (Intercept) to Intercept for ( i in 1:ncol(result) ) { @@ -112,7 +116,11 @@ setMethod("extract.samples", "map", function(object,n=1e4,...){ # require(MASS) # import now, so no need to require? mu <- object@coef - result <- as.data.frame( mvrnorm( n=n , mu=mu , Sigma=vcov(object) ) ) + if ( n==1 ) { + result <- as.data.frame( t( mvrnorm( n=n , mu=mu , Sigma=vcov(object) ) ) ) + } else { + result <- as.data.frame( mvrnorm( n=n , mu=mu , Sigma=vcov(object) ) ) + } # convert vector parameters to vectors in list veclist <- attr(object,"veclist") name_head <- function(aname) strsplit( aname , "[" , fixed=TRUE )[[1]][1] diff --git a/R/sim.r b/R/sim.r index 7948665..3739d40 100644 --- a/R/sim.r +++ b/R/sim.r @@ -17,7 +17,7 @@ sim_core <- function( fit , data , post , vars , n , refresh=0 , replace=list() f <- fit@formula[[1]] for ( i in 1:length(fit@formula) ) { f <- fit@formula[[i]] - left <- as.character( f[[2]] ) + left <- deparse( f[[2]] ) if ( left==var ) { if ( debug==TRUE ) print(f) break