{"id":32207282,"url":"https://github.com/yukai-yang/smfilter","last_synced_at":"2025-10-22T05:50:50.692Z","repository":{"id":56937058,"uuid":"157804691","full_name":"yukai-yang/SMFilter","owner":"yukai-yang","description":"an R package implementing the filtering algorithms for the state-space models on the Stiefel manifold","archived":false,"fork":false,"pushed_at":"2025-05-24T21:57:35.000Z","size":402,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-22T05:50:50.097Z","etag":null,"topics":["cran","filtering","filtering-algorithm","nonlinear-dynamics","nonlinear-optimization","reduced-rank-parameters","sampling","simulated-data","smoothing","state-space-models","stiefel-manifold","time-series-models"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yukai-yang.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-11-16T02:59:39.000Z","updated_at":"2025-05-24T21:57:28.000Z","dependencies_parsed_at":"2022-08-21T01:10:24.153Z","dependency_job_id":"8a23f037-c9ee-41f1-b4b1-20f6f9315662","html_url":"https://github.com/yukai-yang/SMFilter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/yukai-yang/SMFilter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yukai-yang%2FSMFilter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yukai-yang%2FSMFilter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yukai-yang%2FSMFilter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yukai-yang%2FSMFilter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yukai-yang","download_url":"https://codeload.github.com/yukai-yang/SMFilter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yukai-yang%2FSMFilter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280389295,"owners_count":26322507,"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-10-22T02:00:06.515Z","response_time":63,"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":["cran","filtering","filtering-algorithm","nonlinear-dynamics","nonlinear-optimization","reduced-rank-parameters","sampling","simulated-data","smoothing","state-space-models","stiefel-manifold","time-series-models"],"created_at":"2025-10-22T05:50:46.686Z","updated_at":"2025-10-22T05:50:50.684Z","avatar_url":"https://github.com/yukai-yang.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\nSMFilter version 1.0.4 (Red Filter)\n===================================\n\n[![CRAN\\_Status\\_Badge](http://www.r-pkg.org/badges/version/SMFilter?color=green)](https://cran.r-project.org/package=SMFilter) ![](http://cranlogs.r-pkg.org/badges/grand-total/SMFilter?color=green) ![](http://cranlogs.r-pkg.org/badges/SMFilter?color=green) ![](http://cranlogs.r-pkg.org/badges/last-week/SMFilter?color=green)\n\nThe package implements the filtering algorithms for the state-space models on the Stiefel manifold. It also implements sampling algorithms for uniform, vector Langevin-Bingham and matrix Langevin-Bingham distributions on the Stiefel manifold. You can also find the package on CRAN, see\n\n[SMFilter@CRAN](https://CRAN.R-project.org/package=SMFilter)\n\nand the corresponding paper\n\n[State-Space Models on the Stiefel Manifold with a New Approach to Nonlinear Filtering](https://www.mdpi.com/2225-1146/6/4/48)\n\nHow to install\n--------------\n\nYou can either install the stable version from CRAN\n\n``` r\ninstall.packages(\"SMFilter\")\n```\n\nor install the development version from GitHub\n\n``` r\ndevtools::install_github(\"yukai-yang/SMFilter\")\n```\n\nprovided that the package \"devtools\" has been installed beforehand.\n\nExample\n-------\n\nAfter installing the package, you need to load (attach better say) it by running the code\n\n``` r\nlibrary(SMFilter)\n```\n\nYou can first check the information and the current version number by running\n\n``` r\nversion()\n#\u003e SMFilter version 1.0.3 (Red Filter)\n```\n\nThen you can take a look at all the available functions and data in the package\n\n``` r\nls( grep(\"SMFilter\", search()) ) \n#\u003e [1] \"FDist2\"       \"FilterModel1\" \"FilterModel2\" \"rmLB_sm\"     \n#\u003e [5] \"runif_sm\"     \"rvlb_sm\"      \"SimModel1\"    \"SimModel2\"   \n#\u003e [9] \"version\"\n```\n\n### Type one model\n\nFor details, see\n\n``` r\n?SimModel1\n```\n\nFirst we can use the package to sample from the type one model. To this end, we shall initialize by running\n\n``` r\nset.seed(1) # control the seed\niT = 100 # sample size\nip = 2 # dimension of the dependent variable\nir = 1 # rank number\niqx = 3 # dimension of the independent variable x_t\niqz=0 # dimension of the independent variable z_t\nik = 0 # lag length\nmethod='max_3' # the optimization methond to use, for details, see FilterModel1\nOmega = diag(ip)*.1 # covariance of the errors\nvD = 50 # diagonal of the D matrix\n```\n\nThen we initialize the data and some other parameters\n\n``` r\nif(iqx==0) mX=NULL else mX = matrix(rnorm(iT*iqx),iT, iqx)\nif(iqz==0) mZ=NULL else mZ = matrix(rnorm(iT*iqz),iT, iqz)\nif(ik==0) mY=NULL else mY = matrix(0, ik, ip)\nalpha_0 = matrix(c(runif_sm(num=1,ip=ip,ir=ir)), ip, ir)\nbeta = matrix(c(runif_sm(num=1,ip=ip*ik+iqx,ir=ir)), ip*ik+iqx, ir)\nif(ip*ik+iqz==0) mB=NULL else mB = matrix(c(runif_sm(num=1,ip=(ip*ik+iqz)*ip,ir=1)), ip, ip*ik+iqz)\n```\n\nThen we can simulate from the model\n\n``` r\nret = SimModel1(iT=iT, mX=mX, mZ=mZ, mY=mY, alpha_0=alpha_0, beta=beta, mB=mB, vD=vD, Omega=Omega)\n```\n\nHave a look at the simulated data\n\n``` r\nmatplot(ret$dData[,1:ip], type=\"l\", ylab=\"simulated data\")\n```\n\n![](rmd_files/README-dat1-1.png)\n\nThen let's apply the filtering algorithm on the data\n\n``` r\nfil = FilterModel1(mY=as.matrix(ret$dData[,1:ip]), mX=mX, mZ=mZ, beta=beta, mB=mB, Omega=Omega, vD=vD, U0=alpha_0, method=method)\n```\n\nThen we compare the filtered modal orientations with the true ones in terms of the squared Frobenius norm distance (normalized).\n\n![](rmd_files/README-dist1-1.png)\n\nWhat if we start with a wrongly specified initial value, −**α**\u003csub\u003e0\u003c/sub\u003e cannot be worse?\n\n![](rmd_files/README-dist11-1.png)\n\n### Type two model\n\nFor details, see\n\n``` r\n?SimModel2\n```\n\nAgain, we start with sampling. We initialize the parameters\n\n``` r\niT = 100\nip = 2\nir = 1\niqx = 4\niqz=0\nik = 0\nOmega = diag(ip)*.1\nvD = 50\n```\n\nThen we initialize the data and some other parameters\n\n``` r\nif(iqx==0) mX=NULL else mX = matrix(rnorm(iT*iqx),iT, iqx)\nif(iqz==0) mZ=NULL else mZ = matrix(rnorm(iT*iqz),iT, iqz)\nif(ik==0) mY=NULL else mY = matrix(0, ik, ip)\nalpha = matrix(c(runif_sm(num=1,ip=ip,ir=ir)), ip, ir)\nbeta_0 = matrix(c(runif_sm(num=1,ip=ip*ik+iqx,ir=ir)), ip*ik+iqx, ir)\nif(ip*ik+iqz==0) mB=NULL else mB = matrix(c(runif_sm(num=1,ip=(ip*ik+iqz)*ip,ir=1)), ip, ip*ik+iqz)\n```\n\nThen we can simulate from the model\n\n``` r\nret = SimModel2(iT=iT, mX=mX, mZ=mZ, mY=mY, alpha=alpha, beta_0=beta_0, mB=mB, vD=vD)\n```\n\nAnd then have a look at the simulated data\n\n``` r\nmatplot(ret$dData[,1:ip], type=\"l\",ylab=\"simulated data\")\n```\n\n![](rmd_files/README-dat2-1.png)\n\nApply the filtering algorithm on the data\n\n``` r\nfil = FilterModel2(mY=as.matrix(ret$dData[,1:ip]), mX=mX, mZ=mZ, alpha=alpha, mB=mB, Omega=Omega, vD=vD, U0=beta_0, method=method)\n```\n\nThen we compare the filtered modal orientations with the true ones in terms of the squared Frobenius norm distance (normalized).\n\n![](rmd_files/README-dist2-1.png)\n\nWhat if we start with a wrongly specified initial value, −**β**\u003csub\u003e0\u003c/sub\u003e cannot be worse?\n\n![](rmd_files/README-dist22-1.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyukai-yang%2Fsmfilter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyukai-yang%2Fsmfilter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyukai-yang%2Fsmfilter/lists"}