MVTR::MvtRegModel(const Mat &X,const Mat &Y, bool add_intercept) : ParamPolicy(new MatrixParams(X.ncol() + add_intercept,Y.ncol()), new SpdParams(Y.ncol()), new UnivParams(default_df)) { Mat XX(add_intercept? cbind(1.0,X) : X); QR qr(XX); Mat Beta(qr.solve(qr.QtY(Y))); Mat resid = Y - XX* Beta; uint n = XX.nrow(); Spd Sig = resid.t() * resid/n; set_Beta(Beta); set_Sigma(Sig); for(uint i=0; i<n; ++i){ Vec y = Y.row(i); Vec x = XX.row(i); NEW(MvRegData, dp)(y,x); DataPolicy::add_data(dp); } }
void MvReg::mle() { set_Beta(suf()->beta_hat()); set_Sigma(suf()->SSE(Beta()) / suf()->n()); }
void RM::mle(){ add_all(); set_Beta(suf()->beta_hat()); set_sigsq(suf()->SSE()/suf()->n()); }