Title: | Fitting Periodic Coefficients Linear Regression Models |
---|---|
Description: | Provides tools for fitting periodic coefficients regression models to data where periodicity plays a crucial role. It allows users to model and analyze relationships between variables that exhibit cyclical or seasonal patterns, offering functions for estimating parameters and testing the periodicity of coefficients in linear regression models. For simple periodic coefficient regression model see Regui et al. (2024) <doi:10.1080/03610918.2024.2314662>. |
Authors: | Slimane Regui [aut, cre] , Abdelhadi Akharif [aut], Amal Mellouk [aut] |
Maintainer: | Slimane Regui <[email protected]> |
License: | GPL |
Version: | 4.4.2 |
Built: | 2024-11-26 20:47:09 UTC |
Source: | CRAN |
A_x_B() function gives A Kronecker product B
A_x_B(A,B)
A_x_B(A,B)
A |
A matrix. |
B |
A matrix. |
A_x_B(A , B)
|
returns the matrix A Kronecker product B, |
A=matrix(rep(1,6),3,2) B=matrix(seq(1,8),2,4 ) A_x_B(A,B)
A=matrix(rep(1,6),3,2) B=matrix(seq(1,8),2,4 ) A_x_B(A,B)
check_periodicity() function allows to detect the periodicity of parameters in the regression model using pseudo_gaussian_test. See Regui et al. (2024) for periodic simple regression model.
,
where
,
,
,
,
,
, and
with
,
,
\Sigma=\left[\begin{array}{cccc}
2 & 1& \ldots&1 \\
1&\ddots & \ddots& \vdots\\
\vdots& \ddots &\ddots & 1 \\
1&\ldots &1 & 2
\end{array}\right]\
,
,
,
,
,
,
, and
with
.
check_periodicity(x,y,s)
check_periodicity(x,y,s)
x |
A list of independent variables with dimension |
y |
A response variable. |
s |
A period of the regression model. |
check_periodicity() |
returns the value of observed statistic, |
Regui, S., Akharif, A., & Mellouk, A. (2024). "Locally optimal tests against periodic linear regression in short panels." Communications in Statistics-Simulation and Computation, 1–15. doi:10.1080/03610918.2024.2314662
library(expm) set.seed(6) n=400 s=4 x1=rnorm(n,0,1.5) x2=rnorm(n,0,0.9) x3=rnorm(n,0,2) x4=rnorm(n,0,1.9) y=rnorm(n,0,2.5) x=list(x1,x2,x3,x4) check_periodicity(x,y,s)
library(expm) set.seed(6) n=400 s=4 x1=rnorm(n,0,1.5) x2=rnorm(n,0,0.9) x3=rnorm(n,0,2) x4=rnorm(n,0,1.9) y=rnorm(n,0,2.5) x=list(x1,x2,x3,x4) check_periodicity(x,y,s)
DELTA() function gives the value of the component of vector DELTA . See Regui et al. (2024) for periodic simple regression model.
\mathbf{\Delta}=
\left[\begin{array}{c}
\mathbf{\Delta}_1 \\
\mathbf{\Delta}_2\\
\mathbf{\Delta}_3
\end{array}\right]\
, where is a vector of dimension
with component
,
is a vector of dimension
with component
,
is a vector of dimension
with component
.
DELTA(x,phi,s,e,sigma)
DELTA(x,phi,s,e,sigma)
x |
A list of independent variables with dimension |
phi |
|
s |
A period of the regression model. |
e |
The residuals vector. |
sigma |
DELTA() |
returns the values of |
Regui, S., Akharif, A., & Mellouk, A. (2024). "Locally optimal tests against periodic linear regression in short panels." Communications in Statistics-Simulation and Computation, 1–15. doi:10.1080/03610918.2024.2314662
estimate_para_adaptive_method() function gives the adaptive estimation of parameters of a periodic coefficients regression model.
estimate_para_adaptive_method(n,s,y,x)
estimate_para_adaptive_method(n,s,y,x)
n |
The length of vector |
s |
A period of the regression model. |
y |
A response variable. |
x |
A list of independent variables with dimension |
beta_ad |
Parameters to be estimated. |
set.seed(6) n=400 s=4 x1=rnorm(n,0,1.5) x2=rnorm(n,0,0.9) x3=rnorm(n,0,2) x4=rnorm(n,0,1.9) y=rnorm(n,0,2.5) x=list(x1,x2,x3,x4) model=lm(y~x1+x2+x3+x4) z=model$residuals estimate_para_adaptive_method(n,s,y,x)
set.seed(6) n=400 s=4 x1=rnorm(n,0,1.5) x2=rnorm(n,0,0.9) x3=rnorm(n,0,2) x4=rnorm(n,0,1.9) y=rnorm(n,0,2.5) x=list(x1,x2,x3,x4) model=lm(y~x1+x2+x3+x4) z=model$residuals estimate_para_adaptive_method(n,s,y,x)
GAMMA() function gives the value of the component of matrix GAMMA . See Regui et al. (2024) for periodic simple regression model.
\mathbf{\Gamma}=\frac{1}{S}
\left[\begin{array}{ccc}
\left(\mathbf{\Gamma}_{11}\right)_{S \times S }&\mathbf{0} & \mathbf{\Gamma}_{13} \\
\mathbf{0} &\left(\mathbf{\Gamma}_{22} \right)_{pS\times pS } &\mathbf{0} \\
\mathbf{\Gamma}_{13} & \mathbf{0}& \left(\mathbf{\Gamma}_{33} \right)_{S\times S}
\end{array}\right]\
, where ,
,
,
,
,
,
, and
.
GAMMA(x,phi,s,z,sigma)
GAMMA(x,phi,s,z,sigma)
x |
A list of independent variables with dimension |
phi |
|
s |
A period of the regression model. |
z |
The residuals vector. |
sigma |
GAMMA() |
returns the matrix |
Regui, S., Akharif, A., & Mellouk, A. (2024). "Locally optimal tests against periodic linear regression in short panels." Communications in Statistics-Simulation and Computation, 1–15. doi:10.1080/03610918.2024.2314662
lm_per() function gives the least squares estimation of parameters, intercept , slope
, and standard deviation
, of a periodic coefficients regression model using LSE_Reg_per and sd_estimation_for_each_s functions.
where
X=
\left[\begin{array}{ccccccccccc}
&\mathbf{X}^1_{1}&0&\ldots & 0& &\mathbf{X}^p_{1}&0&\ldots & 0 \\
& 0&\mathbf{X}^1_{2} &\ldots &0 & &0&\mathbf{X}^p_{2} &\ldots &0\\
\textbf{I}_{S}\otimes \mathbf{1}_{m} &0&0& \ddots&\vdots&\ldots&0& 0&\ddots&\vdots \\
& 0 &0&0 &\mathbf{X}^1_{S}& &0 &0&0 &\mathbf{X}^p_{S}
\end{array}\right]\
,
,
,
,
,
,
is a vector of ones of dimension
,
is the identity matrix of dimension
,
denotes the Kronecker product, and
with
and
.
lm_per(x,y,s)
lm_per(x,y,s)
x |
A list of independent variables with dimension |
y |
A response variable. |
s |
A period of the regression model. |
Residuals |
the residuals, that is response minus fitted values |
Coefficients |
a named vector of coefficients |
Root mean square error |
The root mean square error |
set.seed(6) n=400 s=4 x1=rnorm(n,0,1.5) x2=rnorm(n,0,0.9) x3=rnorm(n,0,2) x4=rnorm(n,0,1.9) y=rnorm(n,0,2.5) x=list(x1,x2,x3,x4) lm_per(x,y,s)
set.seed(6) n=400 s=4 x1=rnorm(n,0,1.5) x2=rnorm(n,0,0.9) x3=rnorm(n,0,2) x4=rnorm(n,0,1.9) y=rnorm(n,0,2.5) x=list(x1,x2,x3,x4) lm_per(x,y,s)
lm_per_AE() function gives the adaptive estimation of parameters, intercept , slope
, and standard deviation
, of a periodic coefficients regression model.
.
lm_per_AE(x,y,s)
lm_per_AE(x,y,s)
x |
A list of independent variables with dimension |
y |
A response variable. |
s |
A period of the regression model. |
Residuals |
the residuals, that is response minus fitted values |
Coefficients |
a named vector of coefficients |
Root mean square error |
The root mean square error |
set.seed(6) n=200 s=2 x1=rnorm(n,0,1.5) x2=rnorm(n,0,0.9) x3=rnorm(n,0,2) x4=rnorm(n,0,1.9) y=rnorm(n,0,2.5) x=list(x1,x2,x3,x4) lm_per_AE(x,y,s)
set.seed(6) n=200 s=2 x1=rnorm(n,0,1.5) x2=rnorm(n,0,0.9) x3=rnorm(n,0,2) x4=rnorm(n,0,1.9) y=rnorm(n,0,2.5) x=list(x1,x2,x3,x4) lm_per_AE(x,y,s)
LSE_Reg_per() function gives the least squares estimation of parameters of a periodic coefficients regression model.
LSE_Reg_per(x,y,s)
LSE_Reg_per(x,y,s)
x |
A list of independent variables with dimension |
y |
A response variable. |
s |
A period of the regression model. |
beta |
Parameters to be estimated. |
X |
Matrix of predictors. |
Y |
The response vector. |
set.seed(6) n=400 s=4 x1=rnorm(n,0,1.5) x2=rnorm(n,0,0.9) x3=rnorm(n,0,2) x4=rnorm(n,0,1.9) y=rnorm(n,0,2.5) x=list(x1,x2,x3,x4) LSE_Reg_per(x,y,s)
set.seed(6) n=400 s=4 x1=rnorm(n,0,1.5) x2=rnorm(n,0,0.9) x3=rnorm(n,0,2) x4=rnorm(n,0,1.9) y=rnorm(n,0,2.5) x=list(x1,x2,x3,x4) LSE_Reg_per(x,y,s)
function phi_n() function gives the value of with
.
phi_n(x)
phi_n(x)
x |
A numeric value. |
returns the value of
pseudo_gaussian_test() function gives the value of the statistic test, , for detecting periodicity of parameters in the regression model. See check_periodicity function.
pseudo_gaussian_test(x,z,s)
pseudo_gaussian_test(x,z,s)
x |
A list of independent variables with dimension |
z |
The residuals vector. |
s |
A period of the regression model. |
returns the value of the statistic test, .
sd_estimation_for_each_s() function gives the estimation of variances, for all
,in a periodic coefficients regression model.
sd_estimation_for_each_s(x,y,s,beta_hat)
sd_estimation_for_each_s(x,y,s,beta_hat)
x |
A list of independent variables with dimension |
y |
A response variable. |
s |
A period of the regression model. |
beta_hat |
The least squares estimation using LSE_Reg_per. |
returns the value of .
set.seed(6) n=400 s=4 x1=rnorm(n,0,1.5) x2=rnorm(n,0,0.9) x3=rnorm(n,0,2) x4=rnorm(n,0,1.9) y=rnorm(n,0,2.5) x=list(x1,x2,x3,x4) beta_hat=LSE_Reg_per(x,y,s)$beta sd_estimation_for_each_s(x,y,s,beta_hat)
set.seed(6) n=400 s=4 x1=rnorm(n,0,1.5) x2=rnorm(n,0,0.9) x3=rnorm(n,0,2) x4=rnorm(n,0,1.9) y=rnorm(n,0,2.5) x=list(x1,x2,x3,x4) beta_hat=LSE_Reg_per(x,y,s)$beta sd_estimation_for_each_s(x,y,s,beta_hat)