Learn R Programming

trendtestR (version 1.0.1)

explore_continuous_trend: Explore linear and GLM trends for continuous data with automatic model selection / Analyse linearer und GLM-Trends fuer kontinuierliche Daten mit automatischer Modellauswahl

Description

Fits linear models or GLMs (Gaussian or Gamma) to continuous time series data, optionally using natural cubic splines. / Passt lineare Modelle oder GLMs (Gaussian oder Gamma) an kontinuierliche Zeitreihendaten an, optional mit natuerlichen kubischen Splines.

Usage

explore_continuous_trend(
  data,
  datum_col,
  value_col,
  group_col = NULL,
  df_spline = 2,
  family = c("auto", "gaussian", "gamma"),
  return_formula = FALSE,
  verbose = FALSE
)

Value

A list containing fitted model, formula, summary, plot, and model diagnostics. / Eine Liste mit Modell, Formel, Zusammenfassung, Plot und Diagnosen:

model

The fitted GLM object. / Das angepasste GLM-Objekt.

summary

Model summary. / Zusammenfassung des Modells.

plot

ggplot2 visualization of the trend. / ggplot2-Visualisierung des Trends.

dispersion_parameter

Estimated dispersion. / Geschaetzter Dispersionsparameter.

model_family_used

Family used for final model. / Verwendete Modellfamilie.

model_selection_info

Information about family selection (if auto). / Hinweise zur Modellauswahl (bei auto).

aic_comparison

Optional AIC comparison table (if auto and gamma used). / Optionale AIC-Vergleichstabelle (bei auto mit Gamma).

messages

Concatenated messages from model fitting. / Konsolidierte Anpassungsmeldungen.

Arguments

data

Dataframe with time series continuous data. / Dataframe mit Zeitreihen-kontinuierlichen Daten.

datum_col

Name of the time column (usually Date). / Name der Zeitspalte (normalerweise Date).

value_col

Name of the continuous value column (dependent variable). / Name der Spalte mit kontinuierlichen Werten (abhaengige Variable).

group_col

Optional. Name of grouping column for interaction. / Optional. Name der Gruppierungsspalte fuer Interaktion.

df_spline

Degrees of freedom for spline (default = 2). Set to 1 for linear trend. / Freiheitsgrade fuer den Spline (Standard = 2). Setze auf 1 fuer linearen Trend.

family

Specifies the GLM family: "auto" (default), "gaussian", or "gamma". / Gibt die GLM-Familie an: "auto" (Standard), "gaussian" oder "gamma".

return_formula

If TRUE, returns the model formula instead of fitting. / Wenn TRUE, wird nur die Modellformel zurueckgegeben.

verbose

Logical. Whether to print model fitting messages. / Ob Anpassungsmeldungen ausgegeben werden sollen.

See Also

[explore_trend_auto()]

Examples

Run this code
# Basic Gaussian GLM on continuous data
df <- data.frame(
  datum = seq.Date(from = as.Date("2023-01-01"), by = "day", length.out = 100),
  value = 5 + sin(1:100 / 10) + rnorm(100)
)
explore_continuous_trend(df, datum_col = "datum", value_col = "value", df_spline = 1)

# Automatische Auswahl zwischen Gaussian und Gamma
df2 <- data.frame(
  datum = seq.Date(from = as.Date("2023-01-01"), by = "day", length.out = 100),
  value = exp(seq(-1, 1, length.out = 100)) + rnorm(100, sd = 0.2)
)
explore_continuous_trend(df2,
                         datum_col = "datum",
                         value_col = "value",
                         df_spline = 2, family = "auto")

Run the code above in your browser using DataLab