{"id":26296160,"url":"https://github.com/rohancyberops/rp1","last_synced_at":"2025-03-15T04:17:08.975Z","repository":{"id":275599460,"uuid":"926584108","full_name":"RohanCyberOps/RP1","owner":"RohanCyberOps","description":"This project performs an analysis of Starbucks (SBUX) stock returns using R. The analysis includes both simple returns and continuously compounded returns (CC returns) for a period of one month. It also calculates the growth of $1 invested in SBUX and provides visual insights through various plots.","archived":false,"fork":false,"pushed_at":"2025-02-03T14:18:34.000Z","size":53,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T19:51:29.891Z","etag":null,"topics":["analysis","cc","data","r","rlanguage","sbux"],"latest_commit_sha":null,"homepage":"","language":"R","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/RohanCyberOps.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}},"created_at":"2025-02-03T14:15:17.000Z","updated_at":"2025-02-25T16:08:41.000Z","dependencies_parsed_at":"2025-02-03T15:38:41.081Z","dependency_job_id":null,"html_url":"https://github.com/RohanCyberOps/RP1","commit_stats":null,"previous_names":["rohancyberops/rp1"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohanCyberOps%2FRP1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohanCyberOps%2FRP1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohanCyberOps%2FRP1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RohanCyberOps%2FRP1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RohanCyberOps","download_url":"https://codeload.github.com/RohanCyberOps/RP1/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243681043,"owners_count":20330155,"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","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":["analysis","cc","data","r","rlanguage","sbux"],"created_at":"2025-03-15T04:17:08.312Z","updated_at":"2025-03-15T04:17:08.962Z","avatar_url":"https://github.com/RohanCyberOps.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# 📊 **SBUX Monthly Returns Analysis** 📈\n\n## Overview\n\nThis project performs an analysis of Starbucks (SBUX) stock returns using R. The analysis includes both **simple returns** and **continuously compounded returns (CC returns)** for a period of one month. It also calculates the **growth of $1 invested in SBUX** and provides visual insights through various plots.\n\n---\n\n## 🔧 **Features**\n\n- **Simple Returns Calculation**: Calculate simple monthly returns for SBUX.\n- **Continuously Compounded Returns**: Convert simple returns to continuously compounded returns.\n- **Visualization**: Plot both simple and CC returns on separate graphs and compare them on the same graph.\n- **Investment Growth**: Compute the future value of a $1 investment in SBUX.\n- **Probabilistic Analysis**: Visualize discrete probability distributions and cumulative distribution functions (CDF).\n\n---\n\n## 💻 **Prerequisites**\n\nEnsure you have R installed along with the necessary libraries:\n\n```R\ninstall.packages(\"psych\")\n```\n\n---\n\n## 📊 **Code Walkthrough**\n\n### **1. Compute Returns**\nWe calculate the **simple returns** for Starbucks and then convert them into **continuously compounded returns**.\n\n```R\n# Simple Returns\nsbux.ret = (sbuxPrices.df[2:n,1] - sbuxPrices.df[1:(n-1),1])/sbuxPrices.df[1:(n-1),1]\n\n# Continuously Compounded Returns\nsbux.ccret = log(1 + sbux.ret)\n```\n\n### **2. Visualization of Returns**\nWe split the screen into two plots: one for simple returns and another for CC returns. \n\n```R\n# Plotting Simple and CC Returns\npar(mfrow=c(2,1))  # Set up plot area\n\nplot(sbux.ret, type=\"l\", col=\"blue\", lwd=2, ylab=\"Return\", main=\"Monthly Simple Returns on SBUX\")\nabline(h=0)\n\nplot(sbux.ccret, type=\"l\", col=\"blue\", lwd=2, ylab=\"Return\", main=\"Monthly Continuously Compounded Returns on SBUX\")\nabline(h=0)\n\npar(mfrow=c(1,1))  # Reset to a single plot\n```\n\n### **3. Growth of $1 Investment**\nNext, we calculate how a $1 investment in SBUX would grow over time.\n\n```R\n# Compute Gross Returns\nsbux.gret = 1 + sbux.ret\n\n# Calculate Future Values\nsbux.fv = cumprod(sbux.gret)\n```\n\n### **4. Probability and Distribution Analysis**\nWe visualize discrete probability distributions and compute cumulative distribution functions (CDF).\n\n```R\n# Probability Distribution for Microsoft Returns\nr.msft = c(-0.3, 0, 0.1, 0.2, 0.5)\nprob.vals = c(0.05, 0.20, 0.50, 0.20, 0.05)\n\nbarplot(prob.vals, names.arg = as.character(r.msft), xlab=\"Return\")\ntitle(\"Annual Return on Microsoft\")\n\n# Plot CDF of Discrete Distribution\ncdf = c(0, 0.05, 0.25, 0.75, 0.95, 1)\nx.vals = c(-0.4, -0.3, 0, 0.1, 0.2, 0.5)\nplot(x.vals, cdf, lwd=4, type=\"S\")\n```\n\n---\n\n## 🛠️ **Functions and Packages Used**\n\n- **read.csv()**: Read data from CSV files.\n- **log()**: Calculate the logarithm for continuous compounding.\n- **par()**: Adjust the plotting area for multiple plots.\n- **cumprod()**: Calculate cumulative product for future value.\n- **barplot() \u0026 plot()**: Visualize the data.\n\n---\n\n## 📝 **Author**\n\n- **Name**: E. Zivot\n- **Date**: Created on September 24, 2009\n- **Last Updated**: June 27, 2011\n\n---\n\n## 📚 **Further Reading**\n\nFor more information on the R functions used, refer to the official R documentation:\n\n- [R Read CSV](https://www.rdocumentation.org/packages/utils/versions/latest/topics/read.csv)\n- [R log function](https://www.rdocumentation.org/packages/base/versions/latest/topics/log)\n\n---\n\n## 📈 **Visualizations**\n\nThe following graphs provide a comprehensive visual representation of SBUX stock performance:\n\n- **Simple Monthly Returns** 📊\n- **Continuously Compounded Returns** 📉\n- **Investment Growth Over Time** 📈\n\n---\n\n## 🚀 **Conclusion**\n\nThis analysis offers insights into SBUX stock performance over the analyzed period. The different return calculations and visualizations help compare investment scenarios.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohancyberops%2Frp1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frohancyberops%2Frp1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohancyberops%2Frp1/lists"}