mgcvUI: An Interactive Interface for the mgcv (Generalized Additive Models) Package

William Bert Craytor

Abstract

mgcvUI is a graphical user interface for the R mgcv package, which fits Generalized Additive Models (GAMs) using penalized regression splines with automatic smoothness selection. It offers three purpose modes—general predictive modeling, real-estate appraisal, and market-area analysis—and guides the user through data import, smooth-term specification, model fitting, diagnostic and effect plots, and downloadable reports. This article documents mgcvUI’s data-format requirements, modeling workflow, output displays, and complete feature reference.

Introduction

History and Background

Generalized Additive Models

Generalized Additive Models (GAMs) were formalized by Trevor Hastie and Robert Tibshirani in their 1990 monograph. GAMs extend the linear model by replacing each linear term \(\beta_j x_j\) with a smooth function \(f_j(x_j)\), so the model becomes:

\[y = \beta_0 + f_1(x_1) + f_2(x_2) + \cdots + f_p(x_p) + \varepsilon\]

Each \(f_j\) is estimated from the data using a penalized regression spline. The smooth functions allow the model to capture nonlinear relationships without the user specifying a functional form in advance. The penalty controls the wiggliness of each smooth, preventing overfitting while allowing enough flexibility to track real patterns.

The mgcv Package

The R package (Mixed GAM Computation Vehicle) was developed by Simon Wood at the University of Bath (Wood 2017). First released in 2001, it is now the standard R implementation of GAMs and ships with every R installation. Its underlying methods are described in a series of papers covering stable multiple smoothing parameter estimation (Wood 2004), thin-plate regression splines (Wood 2003), fast stable REML estimation (Wood 2011), and general smooth model selection (Wood et al. 2016). Key features include:

Comparison with MARS (earth) and Elastic Net (glmnet)

mgcvUI, earthUI, and glmnetUI are companion applications that use different modeling engines. The following table summarizes the key differences:

MARS (Multivariate Adaptive Regression Splines) was introduced by Jerome Friedman in 1991. It builds piecewise linear models by adaptively selecting hinge functions and their knot positions from the data. The R implementation is the package by Stephen Milborrow.

Elastic net regression, implemented in the package by Friedman, Hastie, and Tibshirani (2010), combines Lasso (\(L_1\)) and ridge (\(L_2\)) penalties for simultaneous variable selection and coefficient shrinkage.

The earthUI–mgcvUI Pipeline

A powerful workflow combines earthUI’s automatic knot discovery with mgcvUI’s smooth estimation. When earthUI exports an result file and mgcvUI imports it:

  1. Earth discovers the knots — MARS finds data-driven hinge positions (change points) for each variable.
  2. mgcvUI uses them as anchors — The earth knots become the basis for cubic regression splines ( basis) in the GAM, giving the smooth terms a head start with knot positions that reflect real structure in the data.
  3. mgcv refines the fit — The penalized spline estimation smooths out the piecewise linear earth fit, producing smooth partial effect curves while preserving the general shape discovered by earth.

This pipeline bridges exploratory modelling (earth) with confirmatory modelling (GAM), combining the best of both approaches.

For real estate appraisal and similar applications requiring interpretable, defensible models:

What Is mgcvUI?

mgcvUI is a graphical user interface for the R package. It runs as a local Shiny application — there is no login, no server, and no accounts. You launch it from R, import a dataset (CSV or Excel), configure your model, and fit a GAM interactively.

The application provides a complete workflow: data import, variable configuration with smooth term specification, model fitting with background processing, diagnostic plots, smooth partial effect curves, and downloadable reports in Word, PDF, or HTML format.

Generalized Additive Models replace the linear relationship \(\beta x\) with a smooth function \(f(x)\) for each predictor. This means:

Three Purpose Modes

When you launch mgcvUI, a Purpose radio button at the top of the sidebar lets you choose one of three modes:

In all three modes, the core modeling engine is identical — you are always fitting a GAM via . The purpose setting controls which additional tools and interface elements are available.

Real Estate–Specific Features

When either For Appraisal or Market Area Analysis is selected, mgcvUI activates several features designed for real estate analysis:

Getting Started

To use mgcvUI:

  1. Install the package in R: install.packages("mgcvUI") or install from source.
  2. Launch the application: run mgcvUI::mgcvUI() in R. The app opens in your web browser on port 7880. The app remembers your last-used purpose mode and restores it automatically.
  3. Import your data using the file upload in Section 1 of the sidebar. mgcvUI accepts CSV and Excel files.
  4. Import from earthUI (optional) — Section 2 lets you import an earthUI result .rds file to seed the GAM with earth-discovered knots. Skip this step if you do not have an earthUI result.
  5. Select your Purpose (General, For Appraisal, or Market Area Analysis). Note that changing the purpose resets both the data import and the earthUI import — you must re-import after switching.
  6. Configure variables — choose your target and predictors, set data types, assign any special column roles, and mark variables as factor or linear.
  7. Set mgcv parameters — family, method, gamma, basis type, k, tensor type, interactions, and other options.
  8. Fit the model — click “Fit Mgcv GAM Model” and review the results in the main panel.
  9. Export — download predictions as Excel, generate reports, or (in appraisal mode) compute RCA adjustments and sales grids.

Settings are automatically persisted in a SQLite database and restored when you reload the same input file.

MLS Input Data Requirements

For real estate appraisal and market analysis workflows, your input data typically comes from a Multiple Listing Service (MLS) export. This chapter describes the expected file structure and the columns that mgcvUI can use.

File Format & Structure

mgcvUI accepts CSV and Excel (.xlsx, .xls) files. On import, column names are automatically converted to snake_case — for example, “Living SqFt” becomes living_sqft, “Contract Date” becomes contract_date, and “Sale Price” becomes sale_price. This normalization ensures consistent column references throughout the workflow. The CSV separator and decimal mark used during import are determined by the locale settings (see Chapter 3, “Locale & Regional Settings”).

Your data file should be a flat table with one row per property and one column per attribute. The first row of the file must contain column headers.

Required Columns for Appraisal Mode

While mgcvUI works with any set of columns, the full appraisal workflow benefits from having the following columns:

Spreadsheet column names can be in a foreign language — the “special” names are in English so that the R program can give them special treatment. Otherwise, the given column names show up in the regression models, graphs and, if doing appraisals, the output reports.

Not all columns are required. mgcvUI adapts — if a column is missing, the corresponding feature is simply omitted. However, for real estate pricing models certain columns are highly recommended:

  1. Sale Age — the number of days between the contract sale date and the effective date. If multi-year sales history is being used, sale_age often plays a central role.
  2. Living Area — also goes by names such as “Living Sqft,” “GLA” (gross living area).
  3. Total Bath Count — the total number of full, quarter, half, and 3/4 bathrooms.
  4. Garage Bays or Garage Area — garage spaces or square footage.
  5. Lot Size — the land area of the property.
  6. Longitude, Latitude, and if available Area ID for geographic price variation.

Special Column Naming Conventions

mgcvUI identifies columns by their special type designation, not by their column name. You can name your columns anything you like in the MLS export — what matters is that you assign the correct special type in the Variable Configuration table (Chapter 6).

Data Quality & Completeness

Subject Row Placement

In Appraisal mode, row 1 must be the subject property. All remaining rows are comparable sales. The subject row is excluded from model fitting. After fitting, the model still generates predictions for the subject row.

In Market Area Analysis mode, placing the subject in row 1 is optional.

In General mode, there is no special row handling — all rows are treated equally.

General Purpose Mode

Overview

General Purpose mode is the default when you launch mgcvUI. It provides the complete GAM workflow for any dataset — not just real estate. You can use mgcvUI for scientific data, financial analysis, engineering studies, or any regression problem where smooth nonlinear relationships are expected.

In General mode, the interface omits the real estate–specific features (special columns, sale age, RCA). The sidebar is streamlined to focus on variable selection, parameter configuration, model fitting, and export.

The Sidebar Workflow

The sidebar is organized into numbered, collapsible sections that guide you from data import through export:

1. Import Data — File upload accepting CSV and Excel files. For Excel files with multiple sheets, a sheet selector appears. Column names are automatically converted to snake_case.

2. Import from earthUI (optional) — Import an earthUI result file to seed the GAM with earth-discovered knot positions. This step is optional — skip it if you do not have an earthUI result to import.

3. Project Output Folder — A text field specifying where downloads are saved (defaults to ~/Downloads).

4. Variable Configuration — Target variable selector, response transform (none, log, log10), predictor table with checkboxes for Include, Factor, and Linear. The Special column appears only in Appraisal and Market modes. See Chapter 6 for full details.

5. Mgcv Call Parameters — All model configuration: parameter presets, family, method, gamma, cross-validation, select, basis type, k, tensor type, interaction matrix, and advanced parameters. See Chapter 7 for the complete parameter reference.

6. Fit Mgcv GAM Model — The button that runs the model.

7. Download Output — Exports predictions, residuals, CQA scores, and per-variable contributions as an Excel file. Available in all purpose modes.

8. Download Report — Generates a formatted report (Word, PDF, or HTML) saved to the output folder. Steps 8–10 (RCA Adjustments, Sales Grid, Report) appear only in Appraisal/Market modes; in General mode the report step is numbered 8.

Import from earthUI (Optional)

Section 2 of the sidebar — Import from earthUI — lets you import an earthUI result file. This enables the earth–mgcv pipeline: earth’s data-driven knot positions become anchor points for GAM smooth terms.

When an earthUI result is imported, mgcvUI:

A Clear button removes the imported earth data and resets to standalone mode.

Main Panel Tabs

After data import, the main panel provides the following tabs (model-dependent tabs populate after fitting):

Settings Persistence

mgcvUI automatically saves your configuration to an SQLite database, keyed by the input filename. When you reload the same file, all settings are restored: target selection, predictor checkboxes, data types, mgcv parameters, and interaction matrix. The last-used purpose mode is also persisted globally and restored when the app is relaunched.

Dark Mode

Click the moon/sun icon in the upper-right corner to toggle between Nord Light and Nord Dark themes. The theme preference is saved in localStorage and persists across sessions. All UI elements adapt to the selected theme.

Locale & Regional Settings

mgcvUI supports international number and CSV formatting conventions through a country-based locale system. The Settings dropdown in the title bar provides Country and Paper selectors for 30+ supported countries. Each preset configures:

Click Save as my default to store your locale preferences globally.

Appraisal Mode

When you select For Appraisal as the Purpose, mgcvUI configures itself for single-property valuation. All features described in Chapter 3 remain available; this chapter covers only the appraisal-specific additions.

Subject Row Handling

In appraisal mode, row 1 of your dataset is the subject property and all remaining rows are comparable sales. Your input file must be organized accordingly (see Chapter 2). The subject’s sale price can be left blank or set to any value — mgcvUI automatically treats it as NA during fitting.

After fitting, the model generates predictions for the subject row, which is the basis for the RCA adjustment workflow.

Effective Date & Sale Age

In appraisal and market modes, an Effective Date field appears in the Variable Configuration section (defaulting to today’s date). If you designate a column as contract_date in the Special dropdown, mgcvUI computes a sale_age column — the number of integer days between each sale’s contract date and the effective date. This column is added as a predictor.

When the Effective Date changes, sale_age is automatically recomputed.

Special Column Designations

In appraisal and market modes, a Special dropdown appears for each predictor in the Variable Configuration table. See Chapter 6 for the complete reference of special types and their effects.

RCA Adjustments Overview

The Calculate RCA Adjustments & Download button (visible only in appraisal mode after fitting) computes market-derived adjustments for each comparable relative to the subject. The full RCA workflow is described in Chapter 11.

Market Area Analysis Mode

When you select Market Area Analysis as the Purpose, mgcvUI provides the same real estate–specific features as appraisal mode (special columns, sale age) but is oriented toward analyzing a group of properties rather than valuing a single subject.

Differences from Appraisal Mode

When to Use Market Mode

Market Area Analysis mode is appropriate when you are:

Variable Selection

Section 4 of the sidebar — Variable Configuration — is where you choose which columns participate in the model and how they are treated.

Target Variable

The Target (response) variable dropdown at the top of Section 4 lists every numeric column in your dataset. Select one column as the response variable (e.g., sale price). The target column is automatically excluded from the predictor list.

Response Transform

Below the target selector, a Response Transform dropdown offers three options:

When a log transform is selected, values \(\leq 0\) in the response are automatically filtered out. All output (predictions, contributions, residuals) is automatically back-transformed to the original scale.

The Predictor Table

Below the target selector, a scrollable table lists every remaining column. Checkbox columns use rotated vertical headers for compactness. The column order is:

Factor vs. Smooth vs. Linear: By default, included numeric variables get a smooth term \(f(x)\). Checking Factor creates a categorical term (one coefficient per level). Checking Linear creates a simple linear term \(\beta x\) instead of a smooth. Variables marked as both Factor and Linear are treated as Factor.

Data Type Detection & Overrides

mgcvUI automatically detects data types on import. Numeric, integer, logical, factor, and date columns are recognized. You can override any detection by changing the Type dropdown. Changing types affects how the column is treated in the model.

Special Column Types Reference

In appraisal and market modes, the Special dropdown provides the following options:

Weighting:

Date & Time Types:

Monetary Types:

Size & Location Types:

Age Types:

Display Types:

Parameter Selection

Section 5 of the sidebar — Mgcv Call Parameters — provides access to all configuration options for the GAM. Each parameter has a blue help icon (?) with a tooltip explanation.

Parameter Presets

A dropdown at the top offers two presets that configure sensible defaults for common workflows:

The Earth Pipeline preset is automatically selected when earthUI knots are imported. The cubic regression spline () basis is required for earth knot integration because it allows specifying exact knot positions.

Family

Choose the distribution family for your response variable:

Family Use Case
gaussian Continuous responses (e.g., sale price). Most common.
Gamma Positive continuous responses with variance proportional to the mean.
poisson Count data (e.g., number of sales).
binomial Binary outcomes.
inverse.gaussian Highly right-skewed positive data.

Method

The smoothing parameter estimation method:

Method Description
REML Restricted Maximum Likelihood (default, recommended). Most robust against overfitting.
GCV.Cp Generalized Cross-Validation. Tends to select slightly more complex models.
ML Maximum Likelihood. Similar to REML but can undersmooth.
P-REML Pearson REML variant.
P-ML Pearson ML variant.
GACV.Cp Generalized Approximate Cross-Validation.

Gamma (Smoothing Multiplier)

The gamma parameter multiplies the effective degrees of freedom in the smoothing criterion, encouraging smoother (less wiggly) fits. Default is 1.2.

Value Effect
1.0 Standard smoothing
1.2–1.4 Slightly smoother than default (recommended)
2.0+ Much smoother — good for noisy data or small samples

Higher gamma values guard against overfitting by penalizing complexity more heavily. The Earth Pipeline preset uses 1.4 for additional smoothing when refining earth’s knots.

Cross-Validation

When checked (default), mgcvUI runs 10-fold cross-validation after fitting to compute a CV R-squared. This provides an honest estimate of out-of-sample predictive power.

Select (Shrinkage)

When checked (default), adds an extra penalty to each smooth term that can shrink it to zero. This enables automatic variable selection — unimportant smooth terms are effectively removed from the model. Implemented via in .

Default Basis

The spline basis function type for smooth terms:

Basis Full Name Description
tp Thin plate regression spline Default. Isotropic (no knot placement needed). Good general-purpose choice.
cr Cubic regression spline Allows explicit knot placement. Required for earth knot integration.
ps P-spline Evenly-spaced B-spline basis with difference penalty. Computationally efficient.
bs B-spline Flexible B-spline basis.

Default k (Basis Dimension)

The basis dimension \(k\) controls the maximum wiggliness of each smooth. A value of 0 (the default) means “automatic” — mgcvUI uses \(k = 10\) or the number of earth knots, whichever is appropriate.

Tensor Type

For interactions between continuous variables, two tensor product types are available:

Type Function Description
ti Tensor interaction — models only the interaction effect, with main effects handled separately by univariate terms. Preferred for interpretability.
te Tensor product — models the entire joint effect including main effects. Harder to decompose for RCA adjustments.

Allowed Interactions

A collapsible Allowed Interactions section displays an upper-triangular checkbox matrix for all included smooth (non-linear, non-factor) predictors. Each checkbox enables a tensor product smooth between the corresponding variable pair.

When earthUI knots are imported, earth-detected interactions are pre-checked and locked (highlighted with a yellow background). If the earth model used degree = 1 (no interactions), an informational message is shown.

Factor-by-Smooth Interactions

A separate Factor-by-Smooth Interactions matrix appears when both factor and smooth variables are included. Each checkbox creates a term — a separate smooth curve for each factor level.

Advanced Parameters

A collapsible “Advanced” section exposes additional settings:

Fitting the Model

The Fit Button

Section 6 of the sidebar contains the Fit Mgcv GAM Model button. Clicking it runs the model with your current configuration.

What Happens During Fitting

When you click Fit, mgcvUI:

  1. Validates the configuration — checks for at least one predictor and at least 10 complete rows. Warns if fewer than 50% of rows are complete (listing the columns responsible for most NAs).
  2. Prepares the data — subsets to model-relevant columns only, removes rows with NAs, applies weights (if designated), excludes the subject row (in appraisal mode), applies response transforms.
  3. Builds the GAM formula — constructs smooth terms for numeric predictors, factor terms for categoricals, linear terms for variables marked Linear, and tensor products for selected interactions. Earth knots are embedded as explicit knot positions in basis terms.
  4. Handles edge cases — drops constant variables, converts binary predictors to factors, caps \(k\) to the number of unique values minus 1, augments earth knots with data quantiles when more knots are needed.
  5. Fits the GAM — calls with the constructed formula, family, method, gamma, select, and other parameters.
  6. Runs cross-validation (if enabled) — 10-fold CV computing out-of-sample R-squared.
  7. Updates all result tabs — Summary, Equation, Contribution plots, Diagnostics, and all other tabs are populated.

Background Fitting & Progress

When the package is available, model fitting runs in a background process so the app remains responsive. A dark-themed terminal-style progress overlay shows:

If is not available, fitting runs synchronously (the app freezes until fitting completes).

After successful fitting, a white checkmark appears on the Fit button and a status line shows: “R-sq = X, CV R-sq = X, Dev = X%, AIC = X, n = X.”

Result Tabs

Data Preview

Shows the imported data as an interactive DataTable with horizontal scrolling and 15 rows per page.

Equation

Displays the fitted GAM model in two parts:

Model equation (MathJax-rendered):

Smooth Function Definitions table:

Summary

Six metric cards displayed across the top:

Below the cards:

Variable Importance

A horizontal bar chart showing the relative importance of each model term:

Below the chart, a DataTable shows Term, Type, EDF, Statistic, and p-value, sorted by statistic descending.

Contribution Plots

Every model term that contributes to the predicted value has an interactive plotly contribution plot, displayed in a bordered card. The tab shows plots for all term types:

Univariate Smooth Terms — \(s(x)\)

For log-transformed models, the y-axis is back-transformed to dollar contributions using the formula \(\bar{y} \times (e^{f(x)} - 1)\), making the curves directly interpretable in dollar terms.

For latitude/longitude variables, the slope is shown per 0.001 degrees rather than per degree, since that is a more meaningful geographic increment.

Factor-by-Smooth Terms — \(s(x, \text{by}=\text{factor})\)

One colored line per factor level, overlaid on a single plot. Useful for seeing how a predictor’s effect varies across groups (e.g., different neighborhoods).

Interaction Terms — \(ti(x_1, x_2)\) and \(te(x_1, x_2)\)

Heatmap showing the 2D contribution surface. Color scale: red (negative) \(\to\) white (zero) \(\to\) blue (positive). Hover shows both variable values and the contribution amount.

Parametric Terms — Linear and Factor

Correlation

A heatmap matrix showing Pearson correlations among all numeric predictors. Available immediately after data import — no model fitting required.

Diagnostics

Two sets of diagnostic visualizations:

Diagnostic panel (via ): Four plots — residuals vs fitted, Q-Q plot, histogram of residuals, and response vs fitted values.

Actual vs Predicted scatter plot: Observed vs predicted values with a 45-degree dashed reference line. For log-transformed models, values are back-transformed to the original scale.

RCA Adjustments

Three histogram plots displayed after RCA computation (appraisal/market mode only):

Each histogram shows mean, median, and standard deviation in the subtitle, with dashed reference lines for mean and median.

Anova

A combined ANOVA table merging parametric and smooth terms from the GAM summary. Shows Term, Type (parametric or smooth), and all associated statistics.

Mgcv Output

Raw text output showing:

Sign Check

When earthUI knots are imported, this tab compares the direction of each variable in the earth model with its direction in the GAM:

A status line shows “All directions consistent” or the number of variables with inconsistencies.

Concurvity

Concurvity is the smooth analogue of multicollinearity. This tab shows:

Values above ()0.8 in the “worst” row indicate that a smooth can be well-approximated by the other smooths, suggesting redundancy.

Basis Check

Output from : basis dimension adequacy tests for each smooth term. If a smooth’s \(k\) is too small, this test will flag it with a low p-value, suggesting you should increase \(k\).

Downloading Data

After fitting, the Download Output button (sidebar section 7) exports an Excel file with predictions and diagnostics.

Output Columns

In appraisal mode, row 1 (subject) has residual/cqa/cqa_sf set to NA. Rows are sorted by residual_sf descending when a living_area column is designated.

A white checkmark appears on the download button after successful completion.

CQA Scores

CQA ranks each row’s residual against all others on a 0–10 scale:

RCA Calculations & Downloading

The RCA (Reconciliation by Comparable Adjustment) workflow is available in Appraisal mode only, after fitting the model.

Opening the RCA Dialog

Click the Calculate RCA Adjustments & Download button in sidebar section 8. A modal dialog appears with:

Click Generate to compute and download.

CQA Score Interpolation

  1. Comparables’ CQA scores and residuals are sorted
  2. Linear interpolation () maps your CQA value to a residual
  3. Subject value = model prediction + interpolated residual
  4. Weight-0 rows are treated as if they had the same residual as the subject

Output Columns

A white checkmark appears on the button after successful computation.

Sales Comparison Grid

The Sales Comparison Grid is available in Appraisal mode only, after computing RCA adjustments. It generates a formatted Excel workbook suitable for inclusion in appraisal reports.

Comp Selection Dialog

Clicking the Generate Sales Grid & Download button opens a modal dialog listing all comparable sales. Comps are split into two groups:

Select your comps, then click Generate Sales Grid to create the workbook.

Required special types: contract_date and living_area must be designated. Recommended special types: latitude, longitude, and lot_size — the grid will work without them but some fields will be blank.

Workbook Layout

The generated workbook contains multiple sheets, each holding 3 comps side by side:

Sheet Protection & Residual Cells

Each sheet is protected to prevent accidental edits, but the residual feature value cells are explicitly unlocked. This allows appraisers to enter values for features not in the model while preserving the formula-driven adjustment calculations.

Downloading Reports

Report Formats

Three formats are available:

Reports are saved to the output folder specified in Section 3.

Report Contents

Reports include:

Each section is independently error-protected — if one section fails, it shows an inline error message and the rest of the report generates normally.

A white checkmark appears on the Download Report button after successful generation.

Exporting Model Functions

mgcvUI can export the fitted GAM’s smooth functions as standalone code in multiple languages. Each smooth is evaluated on a 200-point grid and exported as a lookup table with linear interpolation, allowing the model to be used outside of R without any dependency on .

The Export Functions section (available in the report module) offers checkboxes for R, Python, C++, and SQLite. Click Download Functions (.zip) to generate a zip archive.

R Functions

File:

Python Functions

File:

C++ Header

File:

SQLite Database

File:

Comparison with earthUI and glmnetUI

mgcvUI, earthUI, and glmnetUI are companion tools for regression modeling. They share the same data format, special column types, RCA workflow, and demo datasets, but use different modeling engines.

Key Differences

Shared Features

All three tools provide:

Demo Dataset: Appraisal_1.csv

Description

The demo dataset is shared with earthUI and glmnetUI. It is located in the folder of the mgcvUI source, or if earthUI is installed:

demo_file <- system.file("extdata", "Appraisal_1.csv", package = "earthUI")

The file contains 1,502 residential sales (plus 1 subject property in row 1) from a simulated MLS export. The data represents single-family home sales in a multi-area market with a range of property sizes, ages, and locations.

This is not real data, but is based on a realistic neighborhood in Northern California. All identification information has been altered or removed.

Columns

Suggested Quick Start

  1. Launch mgcvUI: mgcvUI::mgcvUI()
  2. Import Appraisal_1.csv via the file upload
  3. Set Purpose to For Appraisal
  4. Select sale_price as the target
  5. Optionally set Response Transform to Log (natural) for proportional adjustments
  6. Assign special types as shown in the table above
  7. Include predictors: sale_age, living_sqft, baths_total, lot_size, area_id (as factor), age, latitude, longitude, garage_spaces
  8. Keep defaults: REML, gamma = 1.2, tp basis, k = auto, select = TRUE
  9. Click Fit Mgcv GAM Model
  10. Review Summary, Contribution (smooth plots), and Diagnostics tabs
  11. Download output (Step 7), review the CQA ranking
  12. Compute RCA adjustments (Step 8) with a CQA score of ~5.00
  13. Generate a Sales Comparison Grid (Step 9) with recommended comps

System Requirements & Troubleshooting

Supported Platforms

mgcvUI runs on macOS, Windows, and Linux. The application is developed and primarily tested on macOS with RStudio. Platform-specific notes are provided below.

R Version

R \(\geq\) 4.1.0 is required. RStudio Desktop (2023.06 or later) is strongly recommended — it bundles pandoc (needed for HTML/PDF reports) and provides a convenient environment for launching the app.

Required R Packages

The following packages are installed automatically as dependencies:

Optional Dependencies

Platform-Specific Notes

macOS

Fewest issues. Homebrew is recommended for system libraries. If PDF reports are needed:

# In R:
install.packages("tinytex")
tinytex::install_tinytex()

Windows

Works well with RStudio Desktop. Key notes:

Linux

Most variable across distributions. Ubuntu/Debian users may need system libraries before R packages will compile:

sudo apt install libcurl4-openssl-dev libssl-dev \
  libxml2-dev libsqlite3-dev libfontconfig1-dev

For PDF reports: tinytex::install_tinytex() or install from the system package manager.

For headless servers (no display), plotly interactive plots render as static fallbacks in reports. The Shiny app itself requires a web browser connection.

Graceful Degradation

mgcvUI is designed to work even when optional components are missing:

Troubleshooting

“PDF option is not available”

No LaTeX installation detected. Run in R:

install.packages("tinytex")
tinytex::install_tinytex()

Then restart the app. The PDF option will appear.

“Settings will not persist”

The SQLite database directory cannot be created or written to. Check permissions on:

“Diagnostics plot unavailable”

The function occasionally fails on complex models (many tensor interactions, non-standard families). This is a known upstream issue. Workaround: run in the R console to see the diagnostic plots directly.

“Report error: number of items to replace…”

This was a known issue in earlier versions related to the package. Ensure you have the latest version of mgcvUI installed. The current version catches this error and produces the report with a placeholder for the diagnostics section.

Port 7880 already in use

If the app fails to start because port 7880 is occupied (from a previous session), run:

# macOS/Linux:
lsof -ti:7880 | xargs kill

# Windows (PowerShell):
Stop-Process -Id (Get-NetTCPConnection -LocalPort 7880).OwningProcess

Package installation fails on Linux

Missing system libraries. Install the development headers listed in the Linux section above, then retry .

References

Wood, S. N. 2003. “Thin-Plate Regression Splines.” Journal of the Royal Statistical Society (B) 65 (1): 95–114. https://doi.org/10.1111/1467-9868.00374.
Wood, S. N. 2004. “Stable and Efficient Multiple Smoothing Parameter Estimation for Generalized Additive Models.” Journal of the American Statistical Association 99 (467): 673–86. https://doi.org/10.1198/016214504000000980.
Wood, S. N. 2011. “Fast Stable Restricted Maximum Likelihood and Marginal Likelihood Estimation of Semiparametric Generalized Linear Models.” Journal of the Royal Statistical Society (B) 73 (1): 3–36. https://doi.org/10.1111/j.1467-9868.2010.00749.x.
Wood, S. N. 2017. Generalized Additive Models: An Introduction with R. 2nd ed. Chapman; Hall/CRC.
Wood, S. N., N. Pya, and B. Säfken. 2016. “Smoothing Parameter and Model Selection for General Smooth Models (with Discussion).” Journal of the American Statistical Association 111: 1548–75. https://doi.org/10.1080/01621459.2016.1180986.