SCM

SCM Repository

[matrix] Diff of /pkg/R/lmer.R
ViewVC logotype

Diff of /pkg/R/lmer.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 813, Thu Jul 21 16:41:42 2005 UTC revision 814, Thu Jul 21 23:05:52 2005 UTC
# Line 867  Line 867 
867      fixed <- obj@fixed      fixed <- obj@fixed
868      varc <- .Call("lmer_coef", mer, 2, PACKAGE = "Matrix")      varc <- .Call("lmer_coef", mer, 2, PACKAGE = "Matrix")
869      b <- .Call("lmer_ranef", mer, PACKAGE = "Matrix")      b <- .Call("lmer_ranef", mer, PACKAGE = "Matrix")
     ans <- array(0, c(nsamp, length(fixed) + length(varc)),  
                  list(NULL,  
                       c(names(fixed),  
                         paste("varc", seq(along = varc), sep = ''))))  
     if (saveb) {  
         blen <- length(unlist(b, recursive = TRUE))  
         ans <- cbind(ans, array(0, c(nsamp, blen),  
                                 list(NULL,  
                                      paste("b", 1:blen, sep = ''))))  
     }  
   
870      ans <- .Call("glmer_MCMCsamp", GSpt, b, fixed, varc, saveb, nsamp,      ans <- .Call("glmer_MCMCsamp", GSpt, b, fixed, varc, saveb, nsamp,
871            PACKAGE = "Matrix")            PACKAGE = "Matrix")
872      if (FALSE) {      .Call("glmer_finalize", GSpt, PACKAGE = "Matrix");
         ## create the samples  
         for (i in 1:nsamp) {  
             ## sample from the conditional distribution of beta given b and y  
             fixed <- .Call("glmer_fixed_update", GSpt, b,  
                            fixed, PACKAGE = "Matrix")  
             ## sample from the conditional distribution of b given beta, varc and y.  
             b <- .Call("glmer_ranef_update", GSpt, fixed, varc,  
                        b, PACKAGE = "Matrix")  
             ## sample from the conditional distribution of varc given b  
             varc <- 1/rgamma(1, shape = shape,  
                              scale = 1/(sum(b[[1]]^2)/2 + betainv))  
             if (saveb)  
                 ans[i,] <- c(fixed, varc, unlist(b, recursive = TRUE))  
             else  
                 ans[i,] <- c(fixed, varc)  
         }  
     }  
873      class(ans) <- "mcmc"      class(ans) <- "mcmc"
874        attr(ans, "mcpar") <- c(1, nsamp, 1)
875      ans      ans
876  }  }
877    

Legend:
Removed from v.813  
changed lines
  Added in v.814

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge