| Title: | Additive Partial Linear Models with Symmetric Autoregressive Errors |
|---|---|
| Description: | Set of tools for fitting the additive partial linear models with symmetric autoregressive errors of order p, or APLMS-AR(p). This setup enables the modeling of a time series response variable using linear and nonlinear structures of a set of explanatory variables, with nonparametric components approximated by natural cubic splines or P-splines. It also accounts for autoregressive error terms with distributions that have lighter or heavier tails than the normal distribution. The package includes various error distributions, such as normal, generalized normal, Student's t, generalized Student's t, power-exponential, and Cauchy distributions. Chou-Chen, S.W., Oliveira, R.A., Raicher, I., Gilberto A. Paula (2024) <doi:10.1007/s00362-024-01590-w>. |
| Authors: | Shu Wei Chou-Chen [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-5495-2486>), Rodrigo A. Oliveira [aut] (ORCID: <https://orcid.org/0000-0003-3328-6669>), Gilberto A. Paula [aut] (ORCID: <https://orcid.org/0000-0002-9906-9942>), Sebastian Sanchez Sandi [ctb] |
| Maintainer: | Shu Wei Chou-Chen <[email protected]> |
| License: | GPL-2 |
| Version: | 0.1.0 |
| Built: | 2026-06-08 07:16:18 UTC |
| Source: | https://github.com/swchouchen/aplms |
Print the AIC of the fitted APLMS model.
## S3 method for class 'aplms' AIC(object, ...)## S3 method for class 'aplms' AIC(object, ...)
object |
APLMS object. |
... |
other arguments |
a numeric value of the corresponding AIC.
data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) AIC(model)data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) AIC(model)
aplms fits additive partial linear models with autoregressive symmetric errors.
This method is suitable for data sets where the response variable is continuous and symmetric,
with either heavy or light tails, and measured over time.
The model includes a parametric component for a set of covariates, while another set of covariates
can be specified as semi-parametric functions, typically time-related.
In this setup, natural cubic splines or cubic P-splines are used to approximate the nonparametric components.
aplms( formula, npc, basis, Knot, data, family = Normal(), p = 1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), init, lam, verbose = FALSE ) ## S3 method for class 'aplms' print(x, ...)aplms( formula, npc, basis, Knot, data, family = Normal(), p = 1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), init, lam, verbose = FALSE ) ## S3 method for class 'aplms' print(x, ...)
formula |
A symbolic description of the parametric component of the model to be fitted. The details of model specification are given under ‘Details’. |
npc |
A vector of names of non parametric component. |
basis |
A vector of names of the basis to be used for each non parametric covariate. |
Knot |
A vector of the number of knots in each non-linear component of the model. |
data |
A data frame containing the variables in the model |
family |
Symmetric error distribution. The implemented distribution are: |
p |
autoregressive order of the error |
control |
optimization rutine. |
init |
A list of initial values for the symmetric error scale, phi, and autoregressive coefficients, rhos. |
lam |
smoothing parameter vector. |
verbose |
Logical; if TRUE, prints estimation progress messages. Default is FALSE. |
x |
APLMS object. |
... |
other arguments |
Returns an object of class “aplms”, a list with following components.
the formula object used.
the family object used.
the npc object used.
the Knot object used.
the lam object used.
Degrees of freedom: n - q - p - 1.
Estimate the asymptotic covariance matrix for the gamma parameters.
The basis to be used for each non parametric covariate.
The summary table of the Wald statistics.
The summary table of the rho and phi parameters.
Basis functions.
Estimated gamma parameters.
Dv values for the symmetric error.
Dm values for the symmetric error.
Dc values for the symmetric error.
Dd values for the symmetric error.
delta_i for the symmetric error.
Observed information matrix of the fitted model.
The estimated loglikelihood function of the fitted model.
The total effective degree of freedom of the model.
The degree of freedom of the parametric components.
The effective degree of freedom of the non parametric components.
Akaike information criterion of the estimated model.
Bayesian information criterion of the estimated model.
Corrected Akaike information criterion of the estimated model.
The generalized cross-validation (GCV).
The fitted response values of the model.
The fitted mean values of the model.
The response residuals
Raw (Ordinary) residuals:
the data object used.
the function call used.
Chou-Chen, S.W., Oliveira, R.A., Raicher, I., Gilberto A. Paula (2024) Additive partial linear models with autoregressive symmetric errors and its application to the hospitalizations for respiratory diseases Stat Papers 65, 5145–5166. doi:10.1007/s00362-024-01590-w
Oliveira, R.A., Paula, G.A. (2021) Additive partial linear models with autoregressive symmetric errors and its application to the hospitalizations for respiratory diseases Comput Stat 36, 2435–2466. doi:10.1007/s00180-021-01106-2
data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) plot(model) summary(model) print(model)data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) plot(model) summary(model) print(model)
Diagnostic Plots for additive partial linear models with symmetric errors
aplms.diag.plot(model, which, labels = NULL, iden = FALSE, ...)aplms.diag.plot(model, which, labels = NULL, iden = FALSE, ...)
model |
an object with the result of fitting additive partial linear models with symmetric errors. |
which |
an optional numeric value with the number of only plot that must be returned. |
labels |
a optional string vector specifying a labels plots. |
iden |
a logical value used to identify observations. If |
... |
graphics parameters to be passed to the plotting routines. |
Return an interactive menu with eleven options to make plots. This menu contains the follows graphics: 1: Response residuals against fited values. 2: Response residuals against time index. 3: Histogram of Response residuals. 4: Autocorrelation function of response residuals. 5: Partial autocorrelation function of response residuals. 6: Conditional quantile residuals against fited values. 7: Conditional quantile residuals against time index. 8: Histogram of conditional quantile residuals. 9: Autocorrelation function of conditional quantile residual. 10: Partial autocorrelation function of conditional quantile residuals. 11: QQ-plot of conditional quantile residuals.
data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) aplms.diag.plot(model, which = 1)data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) aplms.diag.plot(model, which = 1)
Print the BIC of the fitted APLMS model.
## S3 method for class 'aplms' BIC(object, ...)## S3 method for class 'aplms' BIC(object, ...)
object |
APLMS object. |
... |
other arguments |
a numeric value of the corresponding BIC.
data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) BIC(model)data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) BIC(model)
Extract the coefficients of the fitted APLMS model.
## S3 method for class 'aplms' coef(object, ...)## S3 method for class 'aplms' coef(object, ...)
object |
APLMS object. |
... |
other arguments |
A list of vectors of the corresponding estimated parameters.
data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) coef(model)data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) coef(model)
The family object provide an specify details of the model APLMS. The distribution functions are necessary to specify the random component of the regression models with elliptical errors. The code is derived from the archived package gwer (Araujo, Y.A., Cysneiros, F.J.A., and Cysneiros, A.H.M.A., 2022), originally available on CRAN.
## S3 method for class 'elliptical' family(object, ...) Normal() Cauchy() LogisI() LogisII() Student(df = stop("no df argument")) Powerexp(k = stop("no k argument")) Glogis(parma = stop("no alpha=alpha(m) or m argument")) Gstudent(parm = stop("no s or r argument")) Cnormal(parmt = stop("no epsi or sigma argument")) GNormal(nu = stop("no nu argument"))## S3 method for class 'elliptical' family(object, ...) Normal() Cauchy() LogisI() LogisII() Student(df = stop("no df argument")) Powerexp(k = stop("no k argument")) Glogis(parma = stop("no alpha=alpha(m) or m argument")) Gstudent(parm = stop("no s or r argument")) Cnormal(parmt = stop("no epsi or sigma argument")) GNormal(nu = stop("no nu argument"))
object |
an object with the result of the fitted elliptical regression model. |
... |
arguments to be used to form the default control argument if it is not supplied directly. |
df |
degrees of freedom. |
k |
shape parameter. |
parma |
parameter vector (alpha, m). |
parm |
parameter vector (s, r) for this distribuition. |
parmt |
parameters vector (epsi, sigma). |
nu |
degrees of freedom. |
An object of class “family” specifying a list with the follows elements:
family |
character: the family name. |
g0, g1, g2, g3, g4, g5
|
derived fuctions associated with the distribution family defined. |
df |
degree of freedom for t-Student distribution. |
s, r
|
shape parameters for generalized t-Student distribution. |
alpha |
shape parameter for contaminated normal and generalized logistic distributions. |
mp |
shape parameter for generalized logistic distribution. |
epsi, sigmap
|
dispersion parameters for contaminated normal distribution. |
k |
shape parameter for power exponential distribution. |
a famility elliptical object using a Normal distribution.
a famility elliptical object using a Couchy distribution.
a famility elliptical object using a LogisI distribution.
a famility elliptical object using a LogisII distribution.
a famility elliptical object using a Student distribution with a specific degrees of freedom.
a famility elliptical object using an exponential distribution.
a famility elliptical object using a Glogis distribution.
a famility elliptical object using a Gstudent distribution.
a famility elliptical object using a Cnormal distribution
a famility elliptical object using a Gnormal distribution
Fang, K. T., Kotz, S. and NG, K. W. (1990, ISBN:9781315897943). Symmetric Multivariate and Related Distributions. London: Chapman and Hall.
Normal() Powerexp(k=0.1)Normal() Powerexp(k=0.1)
This dataset consists of respiratory diseases hospitalization in Sorocaba, São Paulo, Brazil. The details of the statistical modeling using the APLMS-AR(p) approach can be found in Chou-Chen, et al. (2024). doi:10.1007/s00362-024-01590-w. The hospitalization data of respiratory diseases in Sorocaba city, São Paulo, Brazil are obtained from the Hospital Information System of Brazil’s Unified National Health System (SIH-SUS), and the climatic and pollution data are provided by the QUALAR system.
data(hospitalization)data(hospitalization)
The "data" slot is a data frame with 932 weekly data on the following 29 variables.
Date, year, epidemiologic weeks, and time index.
Respiratory hospitalization count.
Maximum, minimum and average of .
Maximum, minimum and average of .
Maximum, minimum and average of .
Maximum, minimum and average of .
Maximum, minimum and average of .
Maximum, minimum and average of temperature.
Maximum, minimum and average of relative humidity.
Maximum, minimum and average of daily temperature amplitude.
Chou-Chen, S.W., Oliveira, R.A., Raicher, I. et al. (2024) Additive partial linear models with autoregressive symmetric errors and its application to the hospitalizations for respiratory diseases. Stat Papers 65, 5145–5166. doi:10.1007/s00362-024-01590-w
data(hospitalization) head(hospitalization)data(hospitalization) head(hospitalization)
Takes a fitted 'aplms' object and outputs some diagnostic information about the fitting procedure and results. Returns the conformal normal curvature of the fitted 'aplms' model object. The 'case-weight', 'dispersion', 'response', 'explanatory', and 'corAR' perturbations are available.
## S3 method for class 'aplms' influence( model, perturbation = c("case-weight", "dispersion", "response", "explanatory", "corAR"), part = TRUE, ... )## S3 method for class 'aplms' influence( model, perturbation = c("case-weight", "dispersion", "response", "explanatory", "corAR"), part = TRUE, ... )
model |
an object with the result of fitting additive partial linear models with symmetric errors. |
perturbation |
A string vector specifying a perturbation scheme: 'case-weight', 'dispersion', 'response', 'explanatory', and 'corAR'. |
part |
A logical value to indicate whether the influential analysis is performed for |
... |
other arguments. |
A list object containing the conformal normal curvature of the specified perturbations.
data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) influence(model, perturbation = c("case-weight"))data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) influence(model, perturbation = c("case-weight"))
Takes a fitted 'aplms' object and outputs diagnostics of the sensitivity analysis by assessing the effects of perturbations in the model and/or data, on the parameter estimates. The 'case-weight', 'dispersion', 'response', 'explanatory', and 'corAR' perturbations are available.
influenceplot.aplms( model, perturbation = c("case-weight", "dispersion", "response", "explanatory", "corAR"), part = TRUE, C = 4, labels = NULL )influenceplot.aplms( model, perturbation = c("case-weight", "dispersion", "response", "explanatory", "corAR"), part = TRUE, C = 4, labels = NULL )
model |
an object with the result of fitting additive partial linear models with symmetric errors. |
perturbation |
A string vector specifying a perturbation scheme: 'case-weight', 'dispersion', 'response', 'explanatory', and 'corAR'. |
part |
A logical value to indicate whether the influential analysis is performed for |
C |
The cutoff criterion such that |
labels |
label to especify each data point. |
The conformal normal curvature of the specified perturbations is plotted.
data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) influenceplot.aplms(model, perturbation = c("case-weight"))data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) influenceplot.aplms(model, perturbation = c("case-weight"))
Compute and plot the estimated mean and confidence intervals of the non-parametric component of a 'APLMS' object fited by 'aplms()'.
## S3 method for class 'aplms' plot(x, len = 100, plot = TRUE, level = 0.95, ...)## S3 method for class 'aplms' plot(x, len = 100, plot = TRUE, level = 0.95, ...)
x |
an object with the result of fitting additive partial linear models with symmetric errors. |
len |
The desired length of the sequence of covariates to compute the non parametric component functions. |
plot |
a logical value to return plots. Default value is |
level |
Confidence level. |
... |
other arguments. |
Return a list of all non parametric component functions with their confidence intervals. If plot=TRUE, the estimated nonparametric component functions are plotted.
data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) plot(model)data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) plot(model)
Extract Residuals for APLMS fits
## S3 method for class 'aplms' residuals(object, ...)## S3 method for class 'aplms' residuals(object, ...)
object |
an object with the result of fitting additive partial linear models with symmetric errors. |
... |
other arguments. |
Returns a dataframe with the following columns
the residual,
the Pearson residual, and
the normal quantile of the standarized resiudals.
data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) residuals(model)data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) residuals(model)
Print method for "aplms" class
## S3 method for class 'aplms' summary(object, ...)## S3 method for class 'aplms' summary(object, ...)
object |
an object with the result of fitting additive partial linear models with symmetric errors. |
... |
Other arguments passed to or from other methods. |
Prints the main results of the fitted APLMS model.
data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) summary(model)data(temperature) temperature.df = data.frame(temperature,time=1:length(temperature)) model<-aplms::aplms(temperature ~ 1, npc=c("time"), basis=c("cr"),Knot=c(60), data=temperature.df,family=Powerexp(k=0.3),p=1, control = list(tol = 0.001, algorithm1 = c("P-GAM"), algorithm2 = c("BFGS"), Maxiter1 = 20, Maxiter2 = 25), lam=c(10)) summary(model)
Land-ocean temperature index from 1880–2021 (with base period 1951-1980).
data(temperature)data(temperature)
Time series data.
NASA/GISS/GISTEMP
data(temperature)data(temperature)