diff --git a/src/statsmodels/formula.jl b/src/statsmodels/formula.jl index 82c7a74d27..fde0e36466 100644 --- a/src/statsmodels/formula.jl +++ b/src/statsmodels/formula.jl @@ -370,9 +370,12 @@ function modelmat_cols{T<:AbstractFloatMatrix}(::Type{T}, v::PooledDataVector, c ## contrast matrix reindex = [findfirst(contrast.levels, l) for l in levels(v)] contrastmatrix = convert(T, contrast.matrix) - return contrastmatrix[reindex[v.refs], :] + return indexrows(contrastmatrix, reindex[v.refs]) end +indexrows(m::SparseMatrixCSC, ind::Vector{Int}) = m'[:, ind]' +indexrows(m::AbstractMatrix, ind::Vector{Int}) = m[ind, :] + """ expandcols{T<:AbstractFloatMatrix}(trm::Vector{T}) Create pairwise products of columns from a vector of matrices