{"id":32204068,"url":"https://github.com/aefdz/localfda","last_synced_at":"2026-07-16T13:03:40.979Z","repository":{"id":56936013,"uuid":"281724398","full_name":"aefdz/localFDA","owner":"aefdz","description":"Localization processes for functional data analysis. Software companion for the paper “Localization processes for functional data analysis” by Elías, A., Jiménez, R., and Yukich, J. (2020)","archived":false,"fork":false,"pushed_at":"2021-01-04T09:32:47.000Z","size":2362,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-21T17:51:35.942Z","etag":null,"topics":["classification","functional-data-analysis","imputation","outliers-detection"],"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/aefdz.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-22T16:08:57.000Z","updated_at":"2021-01-04T09:32:50.000Z","dependencies_parsed_at":"2022-08-21T01:10:19.001Z","dependency_job_id":null,"html_url":"https://github.com/aefdz/localFDA","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/aefdz/localFDA","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aefdz%2FlocalFDA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aefdz%2FlocalFDA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aefdz%2FlocalFDA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aefdz%2FlocalFDA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aefdz","download_url":"https://codeload.github.com/aefdz/localFDA/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aefdz%2FlocalFDA/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280382978,"owners_count":26321423,"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":["classification","functional-data-analysis","imputation","outliers-detection"],"created_at":"2025-10-22T04:50:48.052Z","updated_at":"2025-10-22T04:50:49.720Z","avatar_url":"https://github.com/aefdz.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ntitle: \"Localization processes for Functional Data Analysis\"\nauthor: \"Antonio Elías\"\ndate: \"22/07/2020\"\noutput:\n  md_document:\n    variant: markdown_github\n---\n\n```{r setup, include=FALSE, message = FALSE, warning = FALSE, fig.align = 'center'}\nknitr::opts_chunk$set(echo = TRUE)\n\nlibrary(ggplot2)\nlibrary(patchwork)\nlibrary(dplyr)\n```\n\nlocalFDA\n=======\n\n\u003c!-- badges: start --\u003e\n[![License](https://img.shields.io/badge/license-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![Travis build status](https://travis-ci.com/aefdz/localFDA.svg?branch=master)](https://travis-ci.com/aefdz/localFDA)\n\u003c!-- badges: end --\u003e\n\n## Overview\n\nSoftware companion for the paper \"Localization processes for functional data analysis\" by Elías, Antonio, Jiménez, Raúl, and Yukich, Joe, (2020) \u003carXiv:2007.16059\u003e. It provides the code for computing localization processes and localization distances and their application to classification and outlier detection problems.\n\n## Installation \n\n```{r, message = FALSE}\n#install the package\ndevtools::install_github(\"aefdz/localFDA\")\n```\n\n```{r}\n#load the package\nlibrary(localFDA)\n```\n\n## Test usage\nLoad the example data and plot it.\n\n```{r}\nX \u003c- exampleData\nn \u003c- ncol(X)\np \u003c- nrow(X)\nt \u003c- as.numeric(rownames(X))\n\n#plot the data set\ndf_functions \u003c- data.frame(ids = rep(colnames(X), each = p),\n                           y = c(X),\n                           x = rep(t, n)\n                           )\n\nfunctions_plot \u003c- ggplot(df_functions) + \n                  geom_line(aes(x = x, y = y, group = ids, color = ids), \n                            color = \"black\", alpha = 0.25) + \n                  xlab(\"t\") + theme(legend.position = \"none\")\n\n\nfunctions_plot\n```\n\n### Compute *kth empirical localization processes*\nEmpirical version of Equation (1) of the paper. For one focal,\n\n```{r}\nfocal \u003c- \"1\"\n\nlocalizarionProcesses_focal \u003c- localizationProcesses(X, focal)$lc\n```\n\nPlot localization processes of order $1, 50, 100$ and $200$:\n\n```{r}\ndf_lc \u003c- data.frame(k = rep(colnames(localizarionProcesses_focal), each = p),\n                           y = c(localizarionProcesses_focal),\n                           x = rep(t, n-1)\n                           )\n\nlc_plots \u003c- list()\nks \u003c- c(1, 50, 100, 200)\n\nfor(i in 1:4){\n  lc_plots[[i]] \u003c- functions_plot + \n                   geom_line(data = filter(df_lc, k == paste0(\"k=\", ks[i])), \n                             aes(x = x, y = y, group = k), \n                             color = \"blue\", size = 1) +\n                   geom_line(data = filter(df_functions, ids == focal), \n                             aes(x = x, y = y, group = ids), \n                             color = \"red\", linetype = \"dashed\", size = 1)+\n                   ggtitle(paste(\"k = \", ks[i]))\n}\n\nwrap_plots(lc_plots)\n\n```\n\n### Compute *kth empirical localization distances*\nEquation (18) of the paper. For one focal,\n\n```{r}\nlocalizationDistances_focal \u003c- localizationDistances(X, focal)\n\nhead(localizationDistances_focal)\n```\n\nPlot the localization distances:\n\n```{r}\ndf_ld \u003c- data.frame(k = names(localizationDistances_focal),\n                           y = localizationDistances_focal,\n                           x = 1:c(n-1)\n                           )\n\n\nldistances_plot \u003c- ggplot(df_ld, aes(x = x, y = y)) + \n                   geom_point() + \n                   ggtitle(\"Localization distances for one focal\") + \n                   xlab(\"kth\") + ylab(\"L\")\n\nldistances_plot\n```\n\n### Sample $\\mu$ and $\\sigma$ \n\n```{r}\nlocalizationStatistics_full \u003c- localizationStatistics(X, robustify = TRUE)\n\n#See the mean and sd estimations for k = 1, 100, 200, 400, 600\n\nlocalizationStatistics_full$trim_mean[c(1, 100, 200, 400, 600)]\nlocalizationStatistics_full$trim_sd[c(1, 100, 200, 400, 600)]\n```\n\n### Classification\n\n```{r}\nX \u003c- classificationData\n\nids_training \u003c- sample(colnames(X), 90)\nids_testing \u003c- setdiff(colnames(X), ids_training)\n\ntrainingSample \u003c- X[,ids_training]\ntestSample \u003c- X[,ids_testing]; colnames(testSample) \u003c- NULL #blind \nclassNames \u003c- c(\"G1\", \"G2\")\n\nclassification_results \u003c- localizationClassifier(trainingSample, testSample, classNames, k_opt = 3)\n\nchecking \u003c- data.frame(real_classs = ids_testing, \n                      predicted_class =classification_results$test$predicted_class)\n\nchecking\n```\n\n### Outlier detection\n\n```{r}\nX \u003c- outlierData\n\noutliers \u003c- outlierLocalizationDistance(X, localrule = 0.95, whiskerrule = 1.5)\n\noutliers$outliers_ld_rule\n```\n\nPlot results,\n\n```{r}\ndf_functions \u003c- data.frame(ids = rep(colnames(X), each = nrow(X)),\n                           y = c(X),\n                           x = rep(seq(from = 0, to = 1, length.out = nrow(X)), ncol(X)))\n                           \n\nfunctions_plot \u003c- ggplot(df_functions) + \n                  geom_line(aes(x = x, y = y, group = ids), \n                            color = \"black\") + \n                  xlab(\"t\") + \n  theme(legend.position = \"bottom\")+\n                  geom_line(data = df_functions[df_functions$ids %in% outliers$outliers_ld_rule,], aes(x = x, y = y, group = ids, color = ids), size = 1) +\n  guides(color = guide_legend(title=\"Detected outliers\"))\n\nfunctions_plot \n\n```\n\n## References\n\nElías, Antonio, Jiménez, Raúl and Yukich, Joe (2020). Localization processes for functional data analysis [https://arxiv.org/abs/2007.16059]\u003chttps://arxiv.org/abs/2007.16059\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faefdz%2Flocalfda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faefdz%2Flocalfda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faefdz%2Flocalfda/lists"}