@@ -44,17 +44,17 @@ namespace lmsol {
44
44
m_y (y),
45
45
m_n(X.rows()),
46
46
m_p(X.cols()),
47
- m_coef(VectorXd::Constant(m_p, ::NA_REAL)),
47
+ m_coef(VectorXd::Constant(m_p, ::NA_REAL)), // #nocov
48
48
m_r(::NA_INTEGER),
49
49
m_fitted(m_n),
50
- m_se(VectorXd::Constant(m_p, ::NA_REAL)),
50
+ m_se(VectorXd::Constant(m_p, ::NA_REAL)), // #nocov
51
51
m_usePrescribedThreshold(false ) {
52
52
}
53
53
54
- lm& lm::setThreshold (const RealScalar& threshold) {
54
+ lm& lm::setThreshold (const RealScalar& threshold) { // #nocov start
55
55
m_usePrescribedThreshold = true ;
56
56
m_prescribedThreshold = threshold;
57
- return *this ;
57
+ return *this ; // #nocov end
58
58
}
59
59
60
60
inline ArrayXd lm::Dplus (const ArrayXd& d) {
@@ -71,16 +71,16 @@ namespace lmsol {
71
71
}
72
72
73
73
/* * Returns the threshold that will be used by certain methods such as rank().
74
- *
74
+ *
75
75
* The default value comes from experimenting (see "LU precision
76
76
* tuning" thread on the Eigen list) and turns out to be
77
- * identical to Higham's formula used already in LDLt.
77
+ * identical to Higham's formula used already in LDLt.
78
78
*
79
79
* @return The user-prescribed threshold or the default.
80
80
*/
81
81
RealScalar lm::threshold () const {
82
82
return m_usePrescribedThreshold ? m_prescribedThreshold
83
- : numeric_limits<double >::epsilon () * m_p;
83
+ : numeric_limits<double >::epsilon () * m_p;
84
84
}
85
85
86
86
ColPivQR::ColPivQR (const Map<MatrixXd> &X, const Map<VectorXd> &y)
@@ -94,8 +94,8 @@ namespace lmsol {
94
94
m_se = Pmat * PQR.matrixQR ().topRows (m_p).
95
95
triangularView<Upper>().solve (I_p ()).rowwise ().norm ();
96
96
return ;
97
- }
98
- MatrixXd Rinv (PQR.matrixQR ().topLeftCorner (m_r, m_r).
97
+ }
98
+ MatrixXd Rinv (PQR.matrixQR ().topLeftCorner (m_r, m_r). // #nocov start
99
99
triangularView<Upper>().
100
100
solve (MatrixXd::Identity (m_r, m_r)));
101
101
VectorXd effects (PQR.householderQ ().adjoint () * y);
@@ -106,25 +106,25 @@ namespace lmsol {
106
106
effects.tail (m_n - m_r).setZero ();
107
107
m_fitted = PQR.householderQ () * effects;
108
108
m_se.head (m_r) = Rinv.rowwise ().norm ();
109
- m_se = Pmat * m_se;
109
+ m_se = Pmat * m_se; // #nocov end
110
110
}
111
-
111
+
112
112
QR::QR (const Map<MatrixXd> &X, const Map<VectorXd> &y) : lm(X, y) {
113
113
HouseholderQR<MatrixXd> QR (X);
114
114
m_coef = QR.solve (y);
115
115
m_fitted = X * m_coef;
116
116
m_se = QR.matrixQR ().topRows (m_p).
117
117
triangularView<Upper>().solve (I_p ()).rowwise ().norm ();
118
118
}
119
-
120
-
119
+
120
+
121
121
Llt::Llt (const Map<MatrixXd> &X, const Map<VectorXd> &y) : lm(X, y) {
122
122
LLT<MatrixXd> Ch (XtX ().selfadjointView <Lower>());
123
123
m_coef = Ch.solve (X.adjoint () * y);
124
124
m_fitted = X * m_coef;
125
125
m_se = Ch.matrixL ().solve (I_p ()).colwise ().norm ();
126
126
}
127
-
127
+
128
128
Ldlt::Ldlt (const Map<MatrixXd> &X, const Map<VectorXd> &y) : lm(X, y) {
129
129
LDLT<MatrixXd> Ch (XtX ().selfadjointView <Lower>());
130
130
Dplus (Ch.vectorD ()); // to set the rank
@@ -136,7 +136,7 @@ namespace lmsol {
136
136
m_fitted = X * m_coef;
137
137
m_se = Ch.solve (I_p ()).diagonal ().array ().sqrt ();
138
138
}
139
-
139
+
140
140
int gesdd (MatrixXd& A, ArrayXd& S, MatrixXd& Vt) {
141
141
int info, mone = -1 , m = A.rows (), n = A.cols ();
142
142
std::vector<int > iwork (8 * n);
@@ -222,7 +222,7 @@ namespace lmsol {
222
222
if (!(colnames).isNULL ())
223
223
coef.attr (" names" ) = clone (CharacterVector (colnames));
224
224
}
225
-
225
+
226
226
VectorXd resid = y - ans.fitted ();
227
227
int rank = ans.rank ();
228
228
int df = (rank == ::NA_INTEGER) ? n - X.cols () : n - rank;
@@ -240,9 +240,8 @@ namespace lmsol {
240
240
}
241
241
}
242
242
243
- // This defines the R-callable function 'fastLm'
243
+ // This defines the R-callable function 'fastLm'
244
244
// [[Rcpp::export]]
245
245
Rcpp::List fastLm_Impl (Rcpp::NumericMatrix X, Rcpp::NumericVector y, int type) {
246
- return lmsol::fastLm (X, y, type);
246
+ return lmsol::fastLm (X, y, type);
247
247
}
248
-
0 commit comments