int main(int argc, char* argv[]) { LogisticRegression lr; LogisticRegressionScoreTest lrst; LogisticRegressionPermutationTest lrpt; Vector y; Matrix x; Matrix cov; LoadVector("input.y", y); LoadMatrix("input.x", x); LoadMatrix("input.cov", cov); Matrix xall; xall = x; xall.StackRight(cov); // 1 + x + cov if (lr.FitLogisticModel(xall, y, 100) == false) { fprintf(stderr, "Fitting failed!\n"); return -1; } Vector& beta = lr.GetCovEst(); Matrix& v = lr.GetCovB(); Vector& pWald = lr.GetAsyPvalue(); fprintf(stdout, "wald_beta\t"); Print(beta); fputc('\n', stdout); fprintf(stdout, "wald_vcov\t"); Print(v); fputc('\n', stdout); fprintf(stdout, "wald_p\t"); Print(pWald[1]); fputc('\n', stdout); if (lrpt.FitLogisticModelCov(xall, 1, y, 2000, -1) == false) { fprintf(stderr, "Fitting failed!\n"); return -1; } fprintf(stdout, "permutation_p\t"); double permu_p = lrpt.getPvalue(); Print(permu_p); fputc('\n', stdout); if (lrst.FitLogisticModel(xall, y, 1, 100) == false) { fprintf(stderr, "Fitting failed!\n"); return -1; } fprintf(stdout, "score_p\t"); double score_p = lrst.GetPvalue(); Print(score_p); fputc('\n', stdout); return 0; };
int main(int argc, char *argv[]) { time_t now = time(0); printf("chisq p = 0.05 cutoff = %f",chidist(3.84, 1.0)); printf("Start analysis at %s \n", ctime(&now)); /* Matrix a(2,2); a[0][0] = 1.0; a[1][1] = 1.0; a[0][1] = a[1][0] = 0.5; SVD svd; svd.InvertInPlace(a); for (int i = 0; i < a.rows; i ++) { for (int j = 0; j < a.cols; j ++) { std::cout << "a[" << i << "]" << "[" << j << "]" << a[i][j] << "\t"; } std::cout << "\n"; } return 0; */ Matrix X; String Xinput = "ExampleX.test"; Vector Y; String Yinput = "ExampleY.test"; if (loadMatrix(X,Xinput) || loadVector(Y, Yinput)) { fprintf(stderr, "Data loading problem!\n"); exit(1); } LogisticRegression lr; if (lr.FitLogisticModel(X, Y, 30) ) { printf("fit all right!\n"); } else { printf("fit failed\n"); } now = time(0); printf("Finsihed analysis at %s \n", ctime(&now)); LogisticRegressionScoreTest lrst; int Xcol = 1; lrst.FitLogisticModel(X,Y,Xcol,30); printf("score p-value is: %lf \n", lrst.getPvalue()); Vector& pvalue = lr.GetAsyPvalue(); printf("wald p-value is: %lf \n", pvalue[Xcol]); return 0; }