{"id":18016268,"url":"https://github.com/egarpor/goffda","last_synced_at":"2025-03-26T18:32:05.777Z","repository":{"id":47665548,"uuid":"209941208","full_name":"egarpor/goffda","owner":"egarpor","description":"Goodness-of-fit tests for functional data analysis. Software companion for \"A goodness-of-fit test for the functional linear model with functional response\"","archived":false,"fork":false,"pushed_at":"2023-10-14T15:45:54.000Z","size":5500,"stargazers_count":10,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-22T06:41:47.352Z","etag":null,"topics":["functional-data-analysis","goodness-of-fit","r","reproducible-research","statistics"],"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/egarpor.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":"2019-09-21T07:08:47.000Z","updated_at":"2024-02-28T10:45:41.000Z","dependencies_parsed_at":"2022-08-21T00:40:31.395Z","dependency_job_id":null,"html_url":"https://github.com/egarpor/goffda","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egarpor%2Fgoffda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egarpor%2Fgoffda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egarpor%2Fgoffda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egarpor%2Fgoffda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egarpor","download_url":"https://codeload.github.com/egarpor/goffda/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245712958,"owners_count":20660325,"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":["functional-data-analysis","goodness-of-fit","r","reproducible-research","statistics"],"created_at":"2024-10-30T04:16:54.707Z","updated_at":"2025-03-26T18:32:05.352Z","avatar_url":"https://github.com/egarpor.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput:\n  md_document:\n    variant: markdown_github\n---\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE, comment = \"#\u003e\", fig.path = \"README/README-\",\n  message = FALSE, warning = FALSE, fig.asp = 1, fig.align = 'center'\n)\n```\n\ngoffda\n======\n\n```{r, echo = FALSE, results = 'asis'}\ncat(\n  badger::badge_license(license = \"GPLv3\", color = \"blue\",\n                        url = \"https://www.gnu.org/licenses/gpl-3.0\"),\n  badger::badge_github_actions(action = \"R-CMD-check\"),\n  badger::badge_cran_release(color = \"green\"),\n  badger::badge_cran_download(pkg = NULL, type = \"grand-total\"),\n  badger::badge_cran_download(pkg = NULL, type = \"last-month\")\n)\n```\n\n\u003c!-- \u003cimg src=\"\" alt=\"goffda  hexlogo\" align=\"right\" width=\"200\" style=\"padding: 0 15px; float: right;\"/\u003e --\u003e\n\n## Overview\n\nSoftware companion for the paper \"*A goodness-of-fit test for the functional linear model with functional response*\" (García-Portugués, Álvarez-Liébana, Álvarez-Pérez and González-Manteiga, 2021). It implements the proposed estimators and goodness-of-fit tests for the functional linear model with scalar response. It also allows to replicate the data application presented.\n\n## Installation\n\nGet the released version from CRAN:\n\n```{r, install-CRAN, eval = FALSE}\n# Install the package\ninstall.packages(\"goffda\")\n\n# Load package\nlibrary(goffda)\n```\n\nAlternatively, get the latest version from GitHub:\n\n```{r, install-GitHub, eval = FALSE}\n# Install the package\nlibrary(devtools)\ninstall_github(\"egarpor/goffda\")\n\n# Load package\nlibrary(goffda)\n```\n\n```{r, load, echo = FALSE}\n# Load package\nlibrary(goffda)\n```\n\n## Usage\n\nThe following are some simple examples of the usage of the main function of the package, `flm_test`. More examples are available in `?flm_test`.\n\n```{r, test}\n# Generate data under H0\nn \u003c- 100\nset.seed(987654321)\nX_fdata \u003c- r_ou(n = n, t = seq(0, 1, l = 101), sigma = 2)\nepsilon \u003c- r_ou(n = n, t = seq(0, 1, l = 101), sigma = 0.5)\nY_fdata \u003c- epsilon\n\n# Test the FLMFR\nflm_test(X = X_fdata, Y = Y_fdata, verbose = FALSE)\n\n# Simple hypothesis\nflm_test(X = X_fdata, Y = Y_fdata, beta0 = 0, verbose = FALSE)\n\n# Generate data under H1\nn \u003c- 100\nset.seed(987654321)\nsample_frm_fr \u003c- r_frm_fr(n = n, scenario = 3, s = seq(0, 1, l = 101),\n                          t = seq(0, 1, l = 101), nonlinear = \"quadratic\")\nX_fdata \u003c- sample_frm_fr[[\"X_fdata\"]]\nY_fdata \u003c- sample_frm_fr[[\"Y_fdata\"]]\n\n# Test the FLMFR\nflm_test(X = X_fdata, Y = Y_fdata, verbose = FALSE)\n```\n\n## AEMET temperatures data\n\nAn illustration of the test application in a real dataset.\n\n```{r, aemet}\n## Data preprocessing\n\n# Load raw data\ndata(\"aemet_temp\")\n\n# Partition the dataset\nwith(aemet_temp, {\n  ind_pred \u003c- which((1974 \u003c= df$year) \u0026 (df$year \u003c= 1993))\n  ind_resp \u003c- which((1994 \u003c= df$year) \u0026 (df$year \u003c= 2013))\n  aemet_temp_pred \u003c\u003c- list(\"df\" = df[ind_pred, ], \"temp\" = temp[ind_pred])\n  aemet_temp_resp \u003c\u003c- list(\"df\" = df[ind_resp, ], \"temp\" = temp[ind_resp])\n})\n\n# Average the temperature on each period\nmean_aemet \u003c- function(x) {\n  m \u003c- tapply(X = 1:nrow(x$temp$data), INDEX = x$df$ind,\n              FUN = function(i) colMeans(x$temp$data[i, , drop = FALSE],\n                                         na.rm = TRUE))\n x$temp$data \u003c- do.call(rbind, m)\n return(x$temp)\n}\n\n# Build predictor and response fdatas\naemet_temp_pred \u003c- mean_aemet(aemet_temp_pred)\naemet_temp_resp \u003c- mean_aemet(aemet_temp_resp)\n\n# Average yearly temperatures\navg_year_pred \u003c- rowMeans(aemet_temp_pred$data)\navg_year_resp \u003c- rowMeans(aemet_temp_resp$data)\n\n# Average temperatures on both periods\nplot(func_mean(aemet_temp_pred), ylim = c(5, 30),\n     main = \"Average AEMET temperature\")\nplot(func_mean(aemet_temp_resp), col = 2, add = TRUE)\nlegend(\"topleft\", legend = c(\"1974-1993\", \"1994-2013\"), col = 1:2, lwd = 2)\n\n# Test composite and simple hypothesis\n(gof \u003c- flm_test(X = aemet_temp_pred, Y = aemet_temp_resp, B = 1e4,\n                 verbose = FALSE, plot_dens = FALSE, plot_proc = FALSE))\nbeta0 \u003c- diag(x = rep(1, length(aemet_temp_pred$argvals)))\nflm_test(X = aemet_temp_pred, Y = aemet_temp_resp, verbose = FALSE,\n         beta0 = beta0, B = 1e4, plot_dens = FALSE, plot_proc = FALSE)\n\n# Visualize estimation\nlev \u003c- seq(-0.022, 0.022, by = 0.004)\ncol \u003c- colorRampPalette(colors = c(\"blue\", \"white\", \"red\"))\nfilled.contour(x = aemet_temp_pred$argvals, y = aemet_temp_resp$argvals,\n               z = gof$fit_flm$Beta_hat, levels = lev, color.palette = col)\n```\n\n## References\n\nGarcía-Portugués, E., Álvarez-Liébana, J., Álvarez-Pérez, G. and González-Manteiga, W. (2021). A goodness-of-fit test for the functional linear model with functional response. *Scandinavian Journal of Statistics*, 48(2):502--528. [doi:10.1111/sjos.12486](https://doi.org/10.1111/sjos.12486)\n\nCuesta-Albertos, J. A., García-Portugués, E., Febrero-Bande, M. and González-Manteiga, W. (2019). Goodness-of-fit tests for the functional linear model based on randomly projected empirical processes. *The Annals of Statistics*, 47(1):439-467. [doi:10.1214/18-AOS1693](https://doi.org/10.1214/18-AOS1693)\n\nFebrero-Bande, M. and Oviedo de la Fuente, M. (2012). Statistical Computing in Functional Data Analysis: The R Package fda.usc. *Journal of Statistical Software*, 51(4):1-28. [doi:10.18637/jss.v051.i04](https://doi.org/10.18637/jss.v051.i04)\n\nGarcía-Portugués, E., González-Manteiga, W. and Febrero-Bande, M. (2014). A goodness-of-fit test for the functional linear model with scalar response. *Journal of Computational and Graphical Statistics*, 23(3):761-778. [doi:10.1080/10618600.2013.812519](https://doi.org/10.1080/10618600.2013.812519)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegarpor%2Fgoffda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegarpor%2Fgoffda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegarpor%2Fgoffda/lists"}