Calculates the MLE of the coefficients of the usual linear regression model (LM).

lm_fit(y, X, w)

Arguments

y

Vector of observations of length n.

X

Mean covariate matrix of size n x p.

w

Optional positive weights vector of length n.

Value

MLE estimate of beta as a vector of length p.

Details

The LM model is defined as $$ \boldsymbol{y}_i \mid \boldsymbol{x}_i \stackrel{\mathrm{ind}}{\sim} \mathcal{N}(\boldsymbol{x}_i'\boldsymbol{\beta}, 1/w_i), $$ where for each subject \(i\), \(y_i\) is the response, \(\boldsymbol{x}_i \in \mathbb{R}^p\) is the mean covariate vector, and \(w_i\) is an optional positive weight (defaults to 1).

Warning: This R wrapper function provides a direct interface to the C++ source code. Incorrect argument specification may lead to abrupt termination of the R session.