[Lme4-commits] r1823 - www/JSS
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jun 7 23:48:39 CEST 2013
Author: dmbates
Date: 2013-06-07 23:48:38 +0200 (Fri, 07 Jun 2013)
New Revision: 1823
Modified:
www/JSS/lmer.jl
Log:
Tighten up the updateL function a bit.
Modified: www/JSS/lmer.jl
===================================================================
--- www/JSS/lmer.jl 2013-06-06 22:16:44 UTC (rev 1822)
+++ www/JSS/lmer.jl 2013-06-07 21:48:38 UTC (rev 1823)
@@ -5,7 +5,7 @@
type MixedModel{Ti<:Union(Int32,Int64)}
L::CholmodFactor{Float64,Ti}
LambdatZt::CholmodSparse{Float64,Ti}
- X::ModelMatrix # (dense) model matrix
+ X::ModelMatrix # fixed-effects model matrix
Xs::Vector{Matrix{Float64}} # X_1,X_2,...,X_k
beta::Vector{Float64}
inds::Matrix{Ti} # n by k
@@ -15,21 +15,20 @@
end
function updateL(m::MixedModel, theta::Vector{Float64})
- n,p = size(m.X)
- lambda = m.lambda
- pvec = map((x)->size(x,1), m.lambda)
- tlen = mapreduce((p)->(p*(p+1))>>1, +, pvec)
- nzmat = reshape(m.LambdatZt.nzvals, (sum(pvec),n))
- tpos = 1; roff = 0 # position in theta, row offset
- for i in 1:length(pvec)
+ n,k = size(m.inds)
+ LamZ = m.LambdatZt
+ N = reshape(LamZ.nzvals, (div(length(LamZ),n),n))
+ lambda = m.lambda; Xs = m.Xs
+ tpos = 1; roff = 0 # position in theta, row offset
+ for i in 1:k
T = lambda[i]
- p_i = size(T,1)
- for j in 1:p_i, i in j:p_i
+ p = size(T,1) # size of i'th template matrix
+ for j in 1:p, i in j:p # fill lower triangle from theta
T[i,j] = theta[tpos]; tpos += 1
if i == j && T[i,j] < 0. error("Negative diagonal element in T") end
end
- gemm!('T','T',1.0,T,Xs[i],0.0,sub(nzmat,roff+(1:p_i),1:n))
- roff += p_i
+ gemm!('T','T',1.0,T,Xs[i],0.0,sub(nzmat,roff+(1:p),1:n))
+ roff += p
end
chm_factorize_p!(m.L,m.LambdaZt,1.)
m
@@ -47,3 +46,4 @@
end
lp
end
+
More information about the Lme4-commits
mailing list