{"id":26583119,"url":"https://github.com/beckversync/bana4040","last_synced_at":"2025-08-04T02:06:15.991Z","repository":{"id":281520098,"uuid":"945525056","full_name":"Beckversync/BANA4040","owner":"Beckversync","description":" Predictive Analytics","archived":false,"fork":false,"pushed_at":"2025-03-15T06:28:25.000Z","size":1803,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-23T21:45:52.708Z","etag":null,"topics":["bonferroni","outlier-detection","r"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Beckversync.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-03-09T16:22:15.000Z","updated_at":"2025-03-16T06:56:28.000Z","dependencies_parsed_at":"2025-06-23T21:49:26.839Z","dependency_job_id":null,"html_url":"https://github.com/Beckversync/BANA4040","commit_stats":null,"previous_names":["beckversync/bana4040"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Beckversync/BANA4040","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beckversync%2FBANA4040","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beckversync%2FBANA4040/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beckversync%2FBANA4040/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beckversync%2FBANA4040/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Beckversync","download_url":"https://codeload.github.com/Beckversync/BANA4040/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Beckversync%2FBANA4040/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268639706,"owners_count":24282665,"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-04T02:00:09.867Z","response_time":79,"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":["bonferroni","outlier-detection","r"],"created_at":"2025-03-23T08:20:26.617Z","updated_at":"2025-08-04T02:06:15.963Z","avatar_url":"https://github.com/Beckversync.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# README for Assignment 1: Model Selection in R\n\n## Data Information\n- **Data File:** `jobs.txt`\n- **Columns:**\n  - `y`: Job proficiency score (first column)\n  - `t1`, `t2`, `t3`, `t4`: Scores on four aptitude tests\n- Ensure to assign appropriate column headings after importing the data.\n\n## Assignment Tasks 1\n1. **Graphical Summaries:** Generate scatterplots of job proficiency against each predictor and interpret what the plots suggest.\n2. **All Possible Regressions:** Fit all 16 possible models with the four predictors and record model selection metrics: `p`, `R2`, `R2a,p`, `PRESSp`, `AICp`, `BICp`, `Mallows Cp`.\n3. **Best Model Selection:** Identify the best model based on each criterion and determine which variable(s) can be excluded.\n4. **Model Fitting \u0026 Diagnostics:** Fit the best model according to `R2a,p` and assess if model assumptions are met.\n5. **Best Model with Two Predictors:** Using `BICp` and `Mallows Cp`, find the best model with two or fewer predictors.\n6. **Validation:** Compare `SSEp` and `PRESSp` for Model 11.\n7. **Automated Search Procedures:** Perform forward selection, backward elimination, and stepwise regression using the `step()` function and compare selected models.\n8. **Model Search with Conditions:** Use the `regsubsets()` function from the `leaps` package to find the best models based on `R2a,p`, `Mallows Cp`, and `BICp`.\n\n## Package Requirements\n- **DAAG Package:** For computing `PRESSp`\n- **Leaps Package:** For `regsubsets()` function\n\n## Additional Notes\n- Ensure all plots and results are properly labeled and interpreted.\n- Check that your models meet statistical assumptions and provide diagnostics when needed.\n- Maintain clear and concise code structure and comments for readability.\n\n##  Assignment Tasks 2 Outlier Detection in Grocery Data using R\n\nThis project aims to detect influential outliers in grocery data using R. The dataset contains weekly activity data from a national grocery retailer, and the analysis focuses on identifying anomalies in the response and predictor variables.\n\n## Dataset Overview\n- **File**: `grocery.xlsx`\n- **Variables**:\n  - **labor**: Total labor hours per week (response variable)\n  - **shipped**: Number of cases shipped in a week\n  - **cost**: Labor cost as a percentage of total costs\n  - **holiday**: Binary indicator (1 if the week includes a holiday, 0 otherwise)\n\n## Analysis Steps\n\n### 1. Residual Analysis\nWe fit a first-order linear regression model without interaction effects and analyze different types of residuals:\n\n```r\nlibrary(readxl)\ndata \u003c- read_excel(\"grocery.xlsx\")\nresult \u003c- lm(labor ~ shipped + cost + holiday, data)\n\n# Visualizing residuals\npar(mfrow = c(1, 3))\n\n# Plot of residuals vs fitted values\nplot(result$fitted.values, result$residuals,\n     main = \"Residuals vs Fitted\",\n     xlab = \"Fitted Values\", ylab = \"Residuals\")\n\n# Plot of standardized residuals vs fitted values\nplot(result$fitted.values, rstandard(result),\n     main = \"Standardized Residuals vs Fitted\",\n     xlab = \"Fitted Values\", ylab = \"Standardized Residuals\")\n\n# Plot of studentized residuals vs fitted values\nplot(result$fitted.values, rstudent(result),\n     main = \"Studentized Residuals vs Fitted\",\n     xlab = \"Fitted Values\", ylab = \"Studentized Residuals\")\n\n# Reset graphics layout\npar(mfrow = c(1, 1))\n```\n\n### 2. Detecting Outliers in the Response Variable\nWe use studentized residuals and the Bonferroni correction to identify potential outliers:\n\n```r\n# Calculate sample size and number of predictors\nn \u003c- nrow(data)\np \u003c- length(coef(result)) - 1\n\n# Compute studentized residuals\nstudent.res \u003c- rstudent(result)\n\n# Calculate critical value using Bonferroni correction\nalpha \u003c- 0.05\ncrit \u003c- qt(1 - alpha / (2 * n), df = n - p - 1)\n\n# Plot studentized residuals with critical thresholds\nplot(student.res,\n     main = \"Studentized Residuals with Critical Values\",\n     ylab = \"Studentized Residuals\")\nabline(h = c(crit, -crit), col = \"red\", lty = 2)\n\n# Identify outliers\noutliers \u003c- which(abs(student.res) \u003e crit)\nprint(\"Indices of potential outliers:\")\nprint(outliers)\n```\n\n## How to Run the Analysis\n1. Ensure that the `grocery.xlsx` file is in your working directory.\n2. Open the R environment (e.g., RStudio, VSCode) and load the provided scripts.\n3. Execute the code blocks in the order presented.\n\n## Results and Observations\n- **Visual analysis**: Residual plots highlight any patterns or anomalies in the data.\n- **Outlier detection**: Identified observations with studentized residuals beyond the Bonferroni-corrected thresholds.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeckversync%2Fbana4040","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeckversync%2Fbana4040","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeckversync%2Fbana4040/lists"}