[Lme4-commits] r1819 - www/JSS
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jun 5 23:46:40 CEST 2013
Author: dmbates
Date: 2013-06-05 23:46:40 +0200 (Wed, 05 Jun 2013)
New Revision: 1819
Added:
www/JSS/lmer.jl
Log:
Sample Julia code to be included.
Added: www/JSS/lmer.jl
===================================================================
--- www/JSS/lmer.jl (rev 0)
+++ www/JSS/lmer.jl 2013-06-05 21:46:40 UTC (rev 1819)
@@ -0,0 +1,25 @@
+using DataFrames
+using Base.LinAlg.BLAS: trmm, gemv!
+
+type MixedModel{Ti<:Union(Int32,Int64)}
+ X::ModelMatrix # (dense) model matrix
+ Xs::Vector{Matrix{Float64}} # X_1,X_2,...,X_k
+ beta::Vector{Float64}
+ inds::Matrix{Ti} # n by k
+ lambda::Vector{Matrix{Float64}} # k lower triangular mats
+ u::Vector{Matrix{Float64}}
+ y::Vector{Float64}
+end
+
+function linpred(m::MixedModel)
+ lp = m.X.m * m.beta # initialize value to X*beta
+ lm = m.lambda
+ Xs = m.Xs
+ for i in 1:length(Xs) # iterate over r.e. terms
+ X = Xs[i]
+ gemv!('N', 1.,
+ trmm('R','L','N','N',1.,lm[i],X) .* m.u[i][m.inds[:,i],:],
+ ones(size(X,2)), 1., lp)
+ end
+ lp
+end
More information about the Lme4-commits
mailing list