Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Exposing rank deficient info

Abierto
#21 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
julia

Línea de trabajo

Start by reading the issue's StatsAPI and GLM examples, then inspect the RegressionModel, LinPredModel, DensePredChol, and eventual DensePredQR entry points mentioned there. Determine whether the API should expose independent and collinear model-matrix column indexes, and confirm the design with the unanswered discussion before attempting an implementation.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

I want to discuss the best way to have an API for RegressionModels that are rank deficient. In particular, I would like to have a mechanism allowing packages interfacing through StatsAPI to recover the collinear columns of the model matrix.

Consider this example (I am going to use GLM.jl):

X1 = randn(100)
X2 = randn(100)
y = X1 + X2 + randn(100)
df = DataFrame(y=y,X1=X1,X2=X2, X3=X1, X4=X1.+X2)
lm_1 = lm(@formula(y~X1+X2+X3+X4), df)

Using the StatsAPI, there is no way to recover the three columns of the model matrix that are linearly independent. However, one can do this by looking at the DensePredChol (and eventually at the DensePredQR).

For instance, if I want to calculate X'X using only these columns, I could do

X = modelmatrix(lm_1)
XX = X'X
ch = lm_1.model.pp.chol
rnk = rank(ch)
XX[1:end .∉ [ch.p[rnk+1:end]], 1:end .∉ [ch[rnk+1:end]]]

and similarly, for the columns of the modelmatrix:

Z = X[:, 1:end .∉ [ch.p[rnk+1:end]]] 

I don't know the best way to expose this at the API level. Maybe something like this?

function StatsAPI.collinearindexes(r::RegressionModel) end

The implementation in GLM could then look something like this:

function GLM.collinearindexes(m::LinPredModel) ## of course only for `CholeskyPivoted` (and `QRPivoted` when implemented)
  ch = m.pp.chol
  rnk = rank(ch)
  return ch.p[1:rnk], ch.p[rnk+1:end]
end

Probably not great. Ideas?

P.S.: This is very useful to make packages like CovarianceMatrices play nice with rank-deficient RegressionModels.

Lenguaje dominante
Julia
Estrellas
19
Forks
11
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de JuliaStats/StatsAPI.jl

Todos los issues de JuliaStats/StatsAPI.jl

Issues similares

Más issues de Julia

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.