# loglikfuncmmmkmv: Calculate the loglikeligood for a general mixed model In SAMM: Some Algorithms for Mixed Models

## Description

Calculate the loglikeligood for the LMM model expressed as

Y=XB+∑_{j=1}^k Z_j G_j+WE,

where Y is the n \times d response variable, X is the n \times q design matrix of q \times d the fixed effects B, Z_j for j=1,2,…,k (k≥q 1) are the n \times q_j design matrices of the q_j \times d random effects G_j, and W is the n \times t design matrix of t \times d residual effecs E. The random effects and the residual are independently distributed, and have matrix variate distributions (G_j\sim N_{q_j \times d}(0_{q_j \times d}, K_j,Σ_j) for j=1,2,…,k and E\sim N_{t \times d}(0_{t \times d}, R,Σ_E)).

## Usage

 1 loglikfuncmmmkmv(Y,X,Zlist, Klist, sigmahatlist, B,W,R ) 

## Arguments

 Y a numeric vector for the parameters (a mapping of the original parameters) X a numeric matrix (see examples and details) Zlist a numeric matrix (see examples and details) Klist a numeric matrix (see examples and details) sigmahatlist a numeric matrix (see examples and details) B bla bla W bla bal R bla bla

bla bla

bla bla

Deniz Akdemir

## Examples

  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 ## Not run: library(SAMM) n=100 nsample=80 rhotrans=5 ar1cov_cppforR(c(rhotrans),matrix(5)) rho=(2/pi)*atan(rhotrans) rho tan((pi/2)*(rho)) M1<-matrix(rbinom(n*300, 2, .2)-1, nrow=n) K1<-relmatcov_cppforR(c(.01), M1) M2<-matrix(rbinom(n*300, 2, .2)-1, nrow=n) K2<-relmatcov_cppforR(c(0.03), M2) W=(diag(5)[sample(1:5,n, replace=TRUE),]) covY<-3*K1+5*K2+10*(W%*%ar1cov_cppforR(c(rhotrans),matrix(5))%*%t(W)) K1[1:5,1:5] dim(W) dim(ar1cov_cppforR(c(6),matrix(5))) Y<-10+crossprod(chol(covY),rnorm(n)) #training set Trainset<-sample(1:n,nsample) ytrain=Y[Trainset] Xtrain=matrix(rep(1, n)[Trainset], ncol=1) Ztrain=diag(n)[Trainset,] Wtrain=W[Trainset,] samout<-SAMM(Y=matrix(ytrain,ncol=1),X=Xtrain, Zlist=list(Ztrain, Ztrain), Klist=list(K1,K2), lambda=0, W=Wtrain,R=list("ar1",c(0),matrix(5,1,1)), Siglist=list("","",""), corfunc=c(F,F,T), corfuncfixed=c(F,F,F), sigfunc=c(F,F,F),mmalg="dermm_reml2", tolparconv=1e-10, tolparinv=1e-10,maxiter=1000,geterrors=F) samout$corfuncparamslist[[3]] rhohat=(2/pi)*atan(samout$corfuncparamslist[[3]]) rhohat ar1cov_cppforR(c(samout\$corfuncparamslist[[3]]),matrix(5,1,1)) ## End(Not run) 

SAMM documentation built on May 2, 2019, 2:08 a.m.