{"id":35125924,"url":"https://github.com/williamjsdavis/itogaussplot","last_synced_at":"2026-05-21T19:37:53.190Z","repository":{"id":107192596,"uuid":"284872072","full_name":"williamjsdavis/ItoGaussPlot","owner":"williamjsdavis","description":"A measure of the variability of linear trends in a time-series observation, as a function of windowing length","archived":false,"fork":false,"pushed_at":"2023-10-17T18:08:51.000Z","size":123,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-10-17T19:25:50.152Z","etag":null,"topics":["r-language","statistics","stochastic-processes","time-series"],"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/williamjsdavis.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}},"created_at":"2020-08-04T03:56:00.000Z","updated_at":"2023-10-17T19:26:08.401Z","dependencies_parsed_at":null,"dependency_job_id":"146da547-682b-469a-8e26-9298a28b904c","html_url":"https://github.com/williamjsdavis/ItoGaussPlot","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/williamjsdavis/ItoGaussPlot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamjsdavis%2FItoGaussPlot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamjsdavis%2FItoGaussPlot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamjsdavis%2FItoGaussPlot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamjsdavis%2FItoGaussPlot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/williamjsdavis","download_url":"https://codeload.github.com/williamjsdavis/ItoGaussPlot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamjsdavis%2FItoGaussPlot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33311945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T12:23:38.849Z","status":"ssl_error","status_checked_at":"2026-05-21T12:22:11.673Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["r-language","statistics","stochastic-processes","time-series"],"created_at":"2025-12-28T02:39:02.151Z","updated_at":"2026-05-21T19:37:53.183Z","avatar_url":"https://github.com/williamjsdavis.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ItoGaussPlot\nAn example of the calculation and displaying of Ito-Gauss plots. It is a measure of the variability of linear trends $B$ in a time-series observation, as a function of windowing length, $w$. Imagine splitting a time-series observation into chunks of length $w$, and fitting a line to each chunk\n\n$A+Bt$\n\nWhat is the variance of the collection of all the linear components, $B$? This statistic has applications in stochastic modelling, see:\n\n- [Variability of Millennial‐Scale Trends in the Geomagnetic Axial Dipole, Buffett et al. (2019)](https://doi.org/10.1029/2019GL085909)\n- [Decadal global temperature variability increases strongly with climate sensitivity, Nijsse et al. (2019)](https://doi.org/10.1038/s41558-019-0527-4)\n\nImport libraries for calculations and getting data.\n\n```R\nlibrary(ItoGaussPlot)\nlibrary(rmatio)\n```\n\nFor this example, we will consider the Ornstein-Ulhenbeck process, \n\n$dx_t=-\\gamma x_t dt + \\sqrt{D}dW_t$\n\nwhere $x_t$ is the amplitude as a function of time, $\\gamma$ is the slope of the drift term, $\\sqrt{D}$ is the amplitude of the noise, and $W_t$ is a [Wiener process](https://en.wikipedia.org/wiki/Wiener_process). A previously calculated realization of this process (calculated using the [Euler-Maruyama method](https://en.wikipedia.org/wiki/Euler–Maruyama_method)) is loaded.\n\n```R\ndata \u003c- read.mat('tX_g1D1e0.dat')\ntime \u003c- data$tX[1,]\namplitude \u003c- data$tX[2,]\ndataVars \u003c- list(gamma=1.0, D=1.0, dt=0.001)\ndataVars$Nt \u003c- ceiling(tail(time, n=1)/dataVars$dt)\n\nplot(time, amplitude, type = 'l',\n     main='Ornstein-Uhlenbeck integration',\n     xlab='Time', ylab='Amplitude')\n```\n\u003cimg src=\"https://user-images.githubusercontent.com/38541020/89318856-37247100-d634-11ea-9ae3-88d89558f145.jpg\" width=\"800\" height=\"auto\"/\u003e\n\nCalculating the variability of trends as a function of windowing length is done with the `stdWindowSlopeCast()` function. The time vector, amplitude vector, and window length(s) are arguments.\n\n```R\nwindows \u003c- 10^seq(-1,2,len=20)\nslopeStds \u003c- stdWindowSlopeCast(time, amplitude, windows)\n```\n\nFor the Ornstein-Ulhenbeck process, a closed form expression of slope variability can be derived.\n\n$\\sigma_B(w) = \\sqrt{24\\gamma D f(\\gamma w)}$\n\nwhere $f(x)$ is the function\n\n$f(x) = x^{-3}-3x^{-4} + 12x^{-6}-e^{-x}\\Big(3x^{-4} + 12x^{-5} + 12x^{-6}\\Big).$\n\n```R\nwindowsTheory \u003c- 10^seq(-1,2,len=50)\nslopeStdsTheory \u003c- OUanalytic(windowsTheory, dataVars$gamma, dataVars$D)\nslopeStdsTheoryLimit \u003c- OUanalytic(windowsTheory, dataVars$gamma, dataVars$D, \"smallW\")\n```\n\nBelow is a plot comparing the numerical calculations and the theoretical values.\n\n```R\nplot(windowsTheory, slopeStdsTheory, \n     log='xy', type = 'l',\n     main='Standard deviation of slope by windowing',\n     xlab='Window length, w', ylab=expression('Std. of slope, σ'[b]))\nlines(windowsTheory, slopeStdsTheoryLimit, lty=2)\npoints(windows, slopeStds, col=\"red\", pch=16)\nlegend(\"topright\", legend=c(\"Theory\", \"Small w limit\", \"Calculation\"),\n       col=c(\"black\", \"black\", \"red\"), lty=c(1,3,0), pch=c(0,0,16), \n       pt.cex=c(0,0,1), lwd=c(1.5,1.5,1), cex=0.8)\n```\n\n\u003cimg src=\"https://user-images.githubusercontent.com/38541020/89319063-7c48a300-d634-11ea-9073-81cb3d20c723.jpg\" width=\"800\" height=\"auto\"/\u003e\n\n## Uneven time-steps\nThe package uses a different algorthm for unevenly spaces time-series.\n\n```R\ndata \u003c- read.mat('tX_g1D1e0NU.dat')\ntimeNU \u003c- data$tX[1,]\namplitudeNU \u003c- data$tX[2,]\ndataVarsNU \u003c- list(gamma=1.0, D=1.0, dt=0.001)\ndataVarsNU$Nt \u003c- ceiling(tail(time, n=1)/dataVars$dt)\n\npar(mfrow=c(1,2))    # set the plotting area into a 1*2 array\nplot(timeNU, amplitudeNU, type = 'l',\n     main='Ornstein-Uhlenbeck integration',\n     xlab='Time', ylab='Amplitude')\nhist(diff(timeNU),\n     main='Histogram of time-steps',\n     xlab='Time-step', ylab='Counts')\n```\n\n\u003cimg src=\"https://user-images.githubusercontent.com/38541020/89319152-971b1780-d634-11ea-867b-8179dabf3def.jpg\" width=\"800\" height=\"auto\"/\u003e\n\nThe `stdWindowSlopeCast()` function is used again, but theuneven timesteps in the time vector cause a different method to be called.\n\n```R\nslopeStdsNU \u003c- stdWindowSlopeCast(timeNU, amplitudeNU, windows)\n```\n\nBelow is a plot comparing the numerical calculations and the theoretical values.\n\n```R\nplot(windowsTheory, slopeStdsTheory, \n     log='xy', type = 'l',\n     main='Standard deviation of slope by windowing',\n     xlab='Window length, w', ylab=expression('Std. of slope, σ'[b]))\nlines(windowsTheory, slopeStdsTheoryLimit, lty=2)\npoints(windows, slopeStdsNU, col=\"red\", pch=16)\nlegend(\"topright\", legend=c(\"Theory\", \"Small w limit\", \"Calculation\"),\n       col=c(\"black\", \"black\", \"red\"), lty=c(1,3,0), pch=c(0,0,16), \n       pt.cex=c(0,0,1), lwd=c(1.5,1.5,1), cex=0.8)\n```\n\n\u003cimg src=\"https://user-images.githubusercontent.com/38541020/89319326-cfbaf100-d634-11ea-8cef-5942ce5d6f5f.jpg\" width=\"800\" height=\"auto\"/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamjsdavis%2Fitogaussplot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilliamjsdavis%2Fitogaussplot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamjsdavis%2Fitogaussplot/lists"}