{"id":30343605,"url":"https://github.com/ivankuchin/coxph","last_synced_at":"2025-08-18T11:14:44.408Z","repository":{"id":298392968,"uuid":"999830810","full_name":"IvanKuchin/coxph","owner":"IvanKuchin","description":"Cox proportional hazards model implementation and example usage.","archived":false,"fork":false,"pushed_at":"2025-07-02T03:11:46.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-02T04:26:01.717Z","etag":null,"topics":["cox","cox-model","cox-proportional-hazards","hazard","statistics","survival-analyis"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IvanKuchin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-10T21:19:16.000Z","updated_at":"2025-07-02T03:11:48.000Z","dependencies_parsed_at":"2025-06-10T22:32:08.717Z","dependency_job_id":"7090b5d5-1093-46ce-acfe-c0c306c08be2","html_url":"https://github.com/IvanKuchin/coxph","commit_stats":null,"previous_names":["ivankuchin/coxph"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/IvanKuchin/coxph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanKuchin%2Fcoxph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanKuchin%2Fcoxph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanKuchin%2Fcoxph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanKuchin%2Fcoxph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IvanKuchin","download_url":"https://codeload.github.com/IvanKuchin/coxph/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IvanKuchin%2Fcoxph/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270982241,"owners_count":24679458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cox","cox-model","cox-proportional-hazards","hazard","statistics","survival-analyis"],"created_at":"2025-08-18T11:14:43.860Z","updated_at":"2025-08-18T11:14:44.396Z","avatar_url":"https://github.com/IvanKuchin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# coxph\n\nCox proportional hazards model implementation in JavaScript (Node.js or browser). This package provides a simple univariate Cox proportional hazards model for survival analysis, along with example usage.\n\n## Features\n- Univariate Cox proportional hazards model for binary covariates\n- p-value calculation\n- No dependencies\n\n## Installation\n\nClone this repository and install dependencies (if any):\n\n```bash\ngit clone https://github.com/IvanKuchin/coxph\ncd coxph\n# No dependencies required for core usage\n```\n\n## API\n\n### `coxphFit(T, E, X, maxIter = 50, tol = 1e-6)`\n- `T`: Array of times\n- `E`: Array of event indicators (0 = censored, 1 = event)\n- `X`: Array of binary covariate (0 = Group 1, 1 = Group 2)\n- Returns: `{ coef, se, hr, coef_lower, coef_upper }`\n\n### `pValue(coef, se)`\n- Returns the p-value for the coefficient and its standard error.\n\n\n## Usage\n\n### Browser Example\n\nYou can use the Cox proportional hazards model directly in the browser by including the module files and using ES6 imports. Example:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"UTF-8\"\u003e\n  \u003ctitle\u003eCoxPH Browser Example\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003cscript type=\"module\"\u003e\n    import { coxphFit } from './module/cox-univariate.js';\n    import { pValue } from './module/p-value.js';\n\n    // Example data\n    const T = [5, 6, 6, 7, 10, 13, 16, 22, 23, 6, 9, 10, 11, 17, 19, 20, 25, 32, 32, 34, 35];\n    const E = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n    const X = Array(T.length).fill(0);\n\n    const result = coxphFit(T, E, X);\n    console.log(result);\n    const p = pValue(result.coef, result.se);\n    console.log(`p-value: ${p}`);\n  \u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\nMake sure to serve your project with a local web server (not via `file://`) to allow ES6 module imports.\n\n### 1. Simple Example\n\nThis example demonstrates fitting a Cox model to two groups with survival data:\n\nRun with:\n```bash\nnode examples/1_simple.js\n```\n\n### 2. Advanced Example\n\nThis example simulates two groups (with and without surgery) and fits the Cox model:\n\nRun with:\n```bash\nnode examples/2_advanced.js\n```\n\n## License\n\nThis project is licensed under the Apache 2.0 License. See the [LICENSE](LICENSE) file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivankuchin%2Fcoxph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivankuchin%2Fcoxph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivankuchin%2Fcoxph/lists"}