00001
00009 #include "party.h"
00010
00011 SEXP
00012 PL2_expectationSym,
00013 PL2_covarianceSym,
00014 PL2_linearstatisticSym,
00015 PL2_expcovinfSym,
00016 PL2_expcovinfssSym,
00017 PL2_sumweightsSym,
00018 PL2_dimensionSym,
00019 PL2_MPinvSym,
00020 PL2_rankSym,
00021 PL2_svdmemSym,
00022 PL2_methodSym,
00023 PL2_jobuSym,
00024 PL2_jobvSym,
00025 PL2_uSym,
00026 PL2_vSym,
00027 PL2_sSym,
00028 PL2_pSym,
00029 PL2_teststatSym,
00030 PL2_pvalueSym,
00031 PL2_tolSym,
00032 PL2_maxptsSym,
00033 PL2_absepsSym,
00034 PL2_relepsSym,
00035 PL2_minprobSym,
00036 PL2_minsplitSym,
00037 PL2_minbucketSym,
00038 PL2_variablesSym,
00039 PL2_transformationsSym,
00040 PL2_is_nominalSym,
00041 PL2_is_ordinalSym,
00042 PL2_is_censoredSym,
00043 PL2_orderingSym,
00044 PL2_levelsSym,
00045 PL2_scoresSym,
00046 PL2_has_missingsSym,
00047 PL2_whichNASym,
00048 PL2_test_trafoSym,
00049 PL2_predict_trafoSym,
00050 PL2_nobsSym,
00051 PL2_ninputsSym,
00052 PL2_linexpcov2sampleSym,
00053 PL2_weightsSym,
00054 PL2_varmemorySym,
00055 PL2_splitstatisticsSym,
00056 PL2_savesplitstatsSym,
00057 PL2_responsesSym,
00058 PL2_inputsSym,
00059 PL2_testtypeSym,
00060 PL2_nresampleSym,
00061 PL2_varctrlSym,
00062 PL2_splitctrlSym,
00063 PL2_gtctrlSym,
00064 PL2_mincriterionSym,
00065 PL2_maxsurrogateSym,
00066 PL2_randomsplitsSym,
00067 PL2_mtrySym,
00068 PL2_dontuseSym,
00069 PL2_dontusetmpSym,
00070 PL2_stumpSym,
00071 PL2_maxdepthSym,
00072 PL2_tgctrlSym,
00073 PL2_ntreeSym,
00074 PL2_replaceSym,
00075 PL2_fractionSym;
00076
00077 SEXP party_init(void) {
00078 PL2_expectationSym = install("expectation");
00079 PL2_covarianceSym = install("covariance");
00080 PL2_linearstatisticSym = install("linearstatistic");
00081 PL2_expcovinfSym = install("expcovinf");
00082 PL2_expcovinfssSym = install("expcovinfss");
00083 PL2_sumweightsSym = install("sumweights");
00084 PL2_dimensionSym = install("dimension");
00085 PL2_MPinvSym = install("MPinv");
00086 PL2_rankSym = install("rank");
00087 PL2_svdmemSym = install("svdmem");
00088 PL2_methodSym = install("method");
00089 PL2_jobuSym = install("jobu");
00090 PL2_jobvSym = install("jobv");
00091 PL2_uSym = install("u");
00092 PL2_vSym = install("v");
00093 PL2_sSym = install("s");
00094 PL2_pSym = install("p");
00095 PL2_teststatSym = install("teststat");
00096 PL2_pvalueSym = install("pvalue");
00097 PL2_tolSym = install("tol");
00098 PL2_maxptsSym = install("maxpts");
00099 PL2_absepsSym = install("abseps");
00100 PL2_relepsSym = install("releps");
00101 PL2_minsplitSym = install("minsplit");
00102 PL2_minprobSym = install("minprob");
00103 PL2_minbucketSym = install("minbucket");
00104 PL2_variablesSym = install("variables");
00105 PL2_transformationsSym = install("transformations");
00106 PL2_is_nominalSym = install("is_nominal");
00107 PL2_is_ordinalSym = install("is_ordinal");
00108 PL2_is_censoredSym = install("is_censored");
00109 PL2_orderingSym = install("ordering");
00110 PL2_levelsSym = install("levels");
00111 PL2_scoresSym = install("scores");
00112 PL2_has_missingsSym = install("has_missings");
00113 PL2_whichNASym = install("whichNA");
00114 PL2_test_trafoSym = install("test_trafo");
00115 PL2_predict_trafoSym = install("predict_trafo");
00116 PL2_nobsSym = install("nobs");
00117 PL2_ninputsSym = install("ninputs");
00118 PL2_linexpcov2sampleSym = install("linexpcov2sample");
00119 PL2_weightsSym = install("weights");
00120 PL2_varmemorySym = install("varmemory");
00121 PL2_splitstatisticsSym = install("splitstatistics");
00122 PL2_savesplitstatsSym = install("savesplitstats");
00123 PL2_responsesSym = install("responses");
00124 PL2_inputsSym = install("inputs");
00125 PL2_testtypeSym = install("testtype");
00126 PL2_nresampleSym = install("nresample");
00127 PL2_varctrlSym = install("varctrl");
00128 PL2_splitctrlSym = install("splitctrl");
00129 PL2_gtctrlSym = install("gtctrl");
00130 PL2_mincriterionSym = install("mincriterion");
00131 PL2_maxsurrogateSym = install("maxsurrogate");
00132 PL2_randomsplitsSym = install("randomsplits");
00133 PL2_mtrySym = install("mtry");
00134 PL2_dontuseSym = install("dontuse");
00135 PL2_dontusetmpSym = install("dontusetmp");
00136 PL2_stumpSym = install("stump");
00137 PL2_maxdepthSym = install("maxdepth");
00138 PL2_tgctrlSym = install("tgctrl");
00139 PL2_ntreeSym = install("ntree"),
00140 PL2_replaceSym = install("replace"),
00141 PL2_fractionSym = install("fraction");
00142 return(R_NilValue);
00143 }
00144
00145
00146
00147 int get_dimension(SEXP object) {
00148 return(INTEGER(GET_SLOT(object, PL2_dimensionSym))[0]);
00149 }
00150
00151 int get_teststat(SEXP object) {
00152 return(INTEGER(GET_SLOT(object, PL2_teststatSym))[0]);
00153 }
00154
00155 int get_pvalue(SEXP object) {
00156 return(INTEGER(GET_SLOT(object, PL2_pvalueSym))[0]);
00157 }
00158
00159 double get_tol(SEXP object) {
00160 return(REAL(GET_SLOT(object, PL2_tolSym))[0]);
00161 }
00162
00163 int get_maxpts(SEXP object) {
00164 return(INTEGER(GET_SLOT(object, PL2_maxptsSym))[0]);
00165 }
00166
00167 double get_abseps(SEXP object) {
00168 return(REAL(GET_SLOT(object, PL2_absepsSym))[0]);
00169 }
00170
00171 double get_releps(SEXP object) {
00172 return(REAL(GET_SLOT(object, PL2_relepsSym))[0]);
00173 }
00174
00175 double get_minsplit(SEXP object) {
00176 return(REAL(GET_SLOT(object, PL2_minsplitSym))[0]);
00177 }
00178
00179 double get_minprob(SEXP object) {
00180 return(REAL(GET_SLOT(object, PL2_minprobSym))[0]);
00181 }
00182
00183 double get_minbucket(SEXP object) {
00184 return(REAL(GET_SLOT(object, PL2_minbucketSym))[0]);
00185 }
00186
00187 SEXP get_transformation(SEXP object, int variable) {
00188 return(VECTOR_ELT(
00189 GET_SLOT(object, PL2_transformationsSym),
00190 variable - 1));
00191 }
00192
00193 SEXP get_test_trafo(SEXP object) {
00194 return(GET_SLOT(object, PL2_test_trafoSym));
00195 }
00196
00197 SEXP get_predict_trafo(SEXP object) {
00198 return(GET_SLOT(object, PL2_predict_trafoSym));
00199 }
00200
00201
00202 SEXP get_variable(SEXP object, int variable) {
00203 return(VECTOR_ELT(
00204 GET_SLOT(object, PL2_variablesSym),
00205 variable - 1));
00206 }
00207
00208 int is_nominal(SEXP object, int variable) {
00209 return(INTEGER(GET_SLOT(object, PL2_is_nominalSym))[variable - 1]);
00210 }
00211
00212 int is_ordinal(SEXP object, int variable) {
00213 return(INTEGER(GET_SLOT(object, PL2_is_ordinalSym))[variable - 1]);
00214 }
00215
00216 int is_censored(SEXP object, int variable) {
00217 return(INTEGER(GET_SLOT(object, PL2_is_censoredSym))[variable - 1]);
00218 }
00219
00220 int has_missings(SEXP object, int variable) {
00221 return(INTEGER(GET_SLOT(object, PL2_has_missingsSym))[variable - 1]);
00222 }
00223
00224 SEXP get_ordering(SEXP object, int variable) {
00225 if (!is_nominal(object, variable)) {
00226 return(VECTOR_ELT(
00227 GET_SLOT(object, PL2_orderingSym),
00228 variable - 1));
00229 } else {
00230 error("Variable %d is not ordered", variable);
00231 return(R_NilValue);
00232 }
00233 }
00234
00235 SEXP get_levels(SEXP object, int variable) {
00236 if (is_nominal(object, variable) ||
00237 is_ordinal(object, variable)) {
00238 return(VECTOR_ELT(
00239 GET_SLOT(object, PL2_levelsSym),
00240 variable - 1));
00241 } else {
00242 error("Variable %d is not an (ordered) factor", variable);
00243 return(R_NilValue);
00244 }
00245 }
00246
00247 SEXP get_scores(SEXP object, int variable) {
00248 if (is_ordinal(object, variable)) {
00249 return(VECTOR_ELT(
00250 GET_SLOT(object, PL2_scoresSym),
00251 variable - 1));
00252 } else {
00253 error("Variable %d is not an ordered factor", variable);
00254 return(R_NilValue);
00255 }
00256 }
00257
00258 SEXP get_missings(SEXP object, int variable) {
00259 if (has_missings(object, variable)) {
00260 return(VECTOR_ELT(
00261 GET_SLOT(object, PL2_whichNASym),
00262 variable - 1));
00263 } else {
00264 error("Variable %d has no missing values", variable);
00265 return(R_NilValue);
00266 }
00267 }
00268
00269 SEXP get_varmemory(SEXP object, int variable) {
00270 return(VECTOR_ELT(GET_SLOT(object, PL2_varmemorySym),
00271 variable - 1));
00272 }
00273
00274 int get_savesplitstats(SEXP object) {
00275 return(INTEGER(GET_SLOT(object, PL2_savesplitstatsSym))[0]);
00276 }
00277
00278 SEXP get_splitstatistics(SEXP object) {
00279 return(GET_SLOT(object, PL2_splitstatisticsSym));
00280 }
00281
00282 int get_nobs(SEXP object) {
00283 return(INTEGER(GET_SLOT(object, PL2_nobsSym))[0]);
00284 }
00285
00286 int get_ninputs(SEXP object) {
00287 return(INTEGER(GET_SLOT(object, PL2_ninputsSym))[0]);
00288 }
00289
00290 SEXP get_weights(SEXP object, int variable) {
00291 return(VECTOR_ELT(GET_SLOT(object, PL2_weightsSym), variable - 1));
00292 }
00293
00294 int get_testtype(SEXP object) {
00295 return(INTEGER(GET_SLOT(object, PL2_testtypeSym))[0]);
00296 }
00297
00298 int get_nresample(SEXP object) {
00299 return(INTEGER(GET_SLOT(object, PL2_nresampleSym))[0]);
00300 }
00301
00302 SEXP get_varctrl(SEXP object) {
00303 return(GET_SLOT(object, PL2_varctrlSym));
00304 }
00305
00306 SEXP get_splitctrl(SEXP object) {
00307 return(GET_SLOT(object, PL2_splitctrlSym));
00308 }
00309
00310 SEXP get_gtctrl(SEXP object) {
00311 return(GET_SLOT(object, PL2_gtctrlSym));
00312 }
00313
00314 SEXP get_tgctrl(SEXP object) {
00315 return(GET_SLOT(object, PL2_tgctrlSym));
00316 }
00317
00318 double get_mincriterion(SEXP object) {
00319 return(REAL(GET_SLOT(object, PL2_mincriterionSym))[0]);
00320 }
00321
00322 int get_maxsurrogate(SEXP object) {
00323 return(INTEGER(GET_SLOT(object, PL2_maxsurrogateSym))[0]);
00324 }
00325
00326 int get_randomsplits(SEXP object) {
00327 return(INTEGER(GET_SLOT(object, PL2_randomsplitsSym))[0]);
00328 }
00329
00330 int get_mtry(SEXP object) {
00331 return(INTEGER(GET_SLOT(object, PL2_mtrySym))[0]);
00332 }
00333
00334 SEXP get_dontuse(SEXP object) {
00335 return(GET_SLOT(object, PL2_dontuseSym));
00336 }
00337
00338 SEXP get_dontusetmp(SEXP object) {
00339 return(GET_SLOT(object, PL2_dontusetmpSym));
00340 }
00341
00342 int get_stump(SEXP object) {
00343 return(INTEGER(GET_SLOT(object, PL2_stumpSym))[0]);
00344 }
00345
00346 int check_depth(SEXP object, int depth) {
00347 int maxdepth;
00348 maxdepth = INTEGER(GET_SLOT(object, PL2_maxdepthSym))[0];
00349 if (maxdepth == 0) return(1);
00350 if (maxdepth < 1) error("maxdepth is less than one");
00351 return(depth <= maxdepth);
00352 }
00353
00354 int get_ntree(SEXP object) {
00355 return(INTEGER(GET_SLOT(object, PL2_ntreeSym))[0]);
00356 }
00357
00358 int get_replace(SEXP object) {
00359 return(INTEGER(GET_SLOT(object, PL2_replaceSym))[0]);
00360 }
00361
00362 double get_fraction(SEXP object) {
00363 return(REAL(GET_SLOT(object, PL2_fractionSym))[0]);
00364 }