MCPcopy Create free account
hub / github.com/apache/madlib / run

Method run

src/modules/regress/marginal.cpp:208–263  ·  view source on GitHub ↗

* @brief Perform the marginal effects transition step */

Source from the content-addressed store, hash-verified

206 * @brief Perform the marginal effects transition step
207 */
208AnyType
209margins_linregr_int_transition::run(AnyType &args) {
210 // Early return because of an exception has been "thrown"
211 // (actually "warning") in the previous invocations
212 if (args[0].isNull())
213 return Null();
214 MarginsLinregrInteractionState<MutableArrayHandle<double> > state = args[0];
215 if (args[1].isNull() || args[2].isNull() ||
216 args[3].isNull() || args[4].isNull()) {
217 return args[0];
218 }
219 MappedColumnVector x;
220 try {
221 // an exception is raised in the backend if args[2] contains nulls
222 MappedColumnVector xx = args[1].getAs<MappedColumnVector>();
223 // x is a const reference, we can only rebind to change its pointer
224 x.rebind(xx.memoryHandle(), xx.size());
225 } catch (const ArrayWithNullException &e) {
226 return args[0];
227 }
228
229 // The following check was added with MADLIB-138.
230 if (!dbal::eigen_integration::isfinite(x)) {
231 //throw std::domain_error("Design matrix is not finite.");
232 warning("Design matrix is not finite.");
233 return Null();
234 }
235
236 MappedColumnVector beta = args[2].getAs<MappedColumnVector>();
237
238 Matrix J_trans = args[4].getAs<MappedMatrix>();
239 J_trans.transposeInPlace(); // we actually pass-in J but transpose since
240 // we only require J^T in our equations
241
242 if (state.numRows == 0) {
243 if (x.size() > std::numeric_limits<uint16_t>::max()) {
244 //throw std::domain_error("Number of independent variables cannot be "
245 // "larger than 65535.");
246 warning("Number of independent variables cannot be larger than 65535.");
247 return Null();
248 }
249 state.initialize(*this,
250 static_cast<uint16_t>(beta.size()),
251 static_cast<uint16_t>(J_trans.rows()));
252 Matrix training_data_vcov = args[3].getAs<MappedMatrix>();
253 state.training_data_vcov = training_data_vcov;
254 }
255
256 // Now do the transition step
257 state.numRows++;
258
259 // compute marginal effects and delta using 1st and 2nd derivatives
260 state.marginal_effects += J_trans * beta;
261 state.delta += J_trans;
262 return state;
263}
264
265

Callers

nothing calls this directly

Calls 15

NullFunction · 0.85
isfiniteFunction · 0.85
warningFunction · 0.85
margins_stateToResultFunction · 0.85
dotFunction · 0.85
transFunction · 0.85
logisticFunction · 0.85
reindexFunction · 0.85
arrayMethod · 0.80
cdfFunction · 0.50
isNullMethod · 0.45
rebindMethod · 0.45

Tested by

no test coverage detected