The function mc_rw builds the components of the
matrix linear predictor associated with random walk models.
This function is generaly used for the analysis of longitudinal
and times series data. The user can specify the order of the random
walk process.
mc_rw(id, time, data, order = 1, proper = FALSE)
| id | name of the column (string) containing the subject index.
Note that this structure was designed to deal with
longitudinal data. For times series data use the same
|
|---|---|
| time | name of the column (string) containing the index indicating the time. |
| data | data set. |
| order | order of the random walk model. |
| proper | logical. |
Bonat, W. H. (2018). Multiple Response Variables Regression Models in R: The mcglm Package. Journal of Statistical Software, 84(4):1--30.
If proper = FALSE a matrix of dgCMatrix class.
If proper = TRUE a list with two matrices of
dgCMatrix class.
mc_id, mc_dist, mc_car,
mc_ma, mc_mixed and mc_compute_rho.
id <- rep(1:2, each = 4) time <- rep(1:4, 2) data <- data.frame("id" = id, "time" = time) mc_rw(id = "id", time = "time", data = data, order = 1, proper = FALSE)#> $Z1 #> 8 x 8 sparse Matrix of class "dsCMatrix" #> #> [1,] 1 -1 . . . . . . #> [2,] -1 2 -1 . . . . . #> [3,] . -1 2 -1 . . . . #> [4,] . . -1 1 . . . . #> [5,] . . . . 1 -1 . . #> [6,] . . . . -1 2 -1 . #> [7,] . . . . . -1 2 -1 #> [8,] . . . . . . -1 1 #>mc_rw(id = "id", time = "time", data = data, order = 1, proper = TRUE)#> $Z1 #> 8 x 8 sparse Matrix of class "dtCMatrix" #> #> [1,] 1 . . . . . . . #> [2,] . 2 . . . . . . #> [3,] . . 2 . . . . . #> [4,] . . . 1 . . . . #> [5,] . . . . 1 . . . #> [6,] . . . . . 2 . . #> [7,] . . . . . . 2 . #> [8,] . . . . . . . 1 #> #> $Z2 #> 8 x 8 sparse Matrix of class "dsCMatrix" #> #> [1,] 0 -1 . . . . . . #> [2,] -1 0 -1 . . . . . #> [3,] . -1 0 -1 . . . . #> [4,] . . -1 0 . . . . #> [5,] . . . . 0 -1 . . #> [6,] . . . . -1 0 -1 . #> [7,] . . . . . -1 0 -1 #> [8,] . . . . . . -1 0 #>mc_rw(id = "id", time = "time", data = data, order = 2, proper = TRUE)#> $Z1 #> 8 x 8 sparse Matrix of class "dtCMatrix" #> #> [1,] 1 . . . . . . . #> [2,] . 5 . . . . . . #> [3,] . . 5 . . . . . #> [4,] . . . 1 . . . . #> [5,] . . . . 1 . . . #> [6,] . . . . . 5 . . #> [7,] . . . . . . 5 . #> [8,] . . . . . . . 1 #> #> $Z2 #> 8 x 8 sparse Matrix of class "dsCMatrix" #> #> [1,] 0 -2 1 . . . . . #> [2,] -2 0 -4 1 . . . . #> [3,] 1 -4 0 -2 . . . . #> [4,] . 1 -2 0 . . . . #> [5,] . . . . 0 -2 1 . #> [6,] . . . . -2 0 -4 1 #> [7,] . . . . 1 -4 0 -2 #> [8,] . . . . . 1 -2 0 #>