Skip to contents

Visualize the model data structure as matrices in LaTeX

Usage

show_data_structure(stack)

Arguments

stack

an object of class inla.stack returned from the function make_inlamemi_stacks, which describes the structure of the data for the measurement error and imputation model.

Value

A list containing data frames with the left hand side (response_df) and right hand side (effects_df), along with the latex code needed to visualize the matrices (matrix_string).

Examples

stack <- make_inlamemi_stacks(data = simple_data,
                   formula_moi = y ~ x + z,
                   formula_imp = x ~ z,
                   error_type = "classical")
show_data_structure(stack)
#> $response_df
#>        y_moi x_classical   x_imp
#> 1      10.81        <NA>    <NA>
#> 2    \\vdots     \\vdots \\vdots
#> 1000    6.18        <NA>    <NA>
#> 1001    <NA>        4.98    <NA>
#> 5    \\vdots     \\vdots \\vdots
#> 2000    <NA>        1.46    <NA>
#> 2001    <NA>        <NA>       0
#> 8    \\vdots     \\vdots \\vdots
#> 3000    <NA>        <NA>       0
#> 
#> $effects_df
#>       beta.0  beta.x  beta.z    id.x weight.x alpha.x.0 alpha.x.z
#> 1          1       1    0.98    <NA>     <NA>      <NA>      <NA>
#> 2    \\vdots \\vdots \\vdots \\vdots  \\vdots   \\vdots   \\vdots
#> 1000       1    1000    0.77    <NA>     <NA>      <NA>      <NA>
#> 1001    <NA>    <NA>    <NA>       1        1      <NA>      <NA>
#> 5    \\vdots \\vdots \\vdots \\vdots  \\vdots   \\vdots   \\vdots
#> 2000    <NA>    <NA>    <NA>    1000        1      <NA>      <NA>
#> 2001    <NA>    <NA>    <NA>      -1       -1         1      0.98
#> 8    \\vdots \\vdots \\vdots \\vdots  \\vdots   \\vdots   \\vdots
#> 3000    <NA>    <NA>    <NA>   -1000       -1         1      0.77
#> 
#> $matrix_string
#> [1] "$$\\underbrace{\\begin{bmatrix} \n10.81 & \\texttt{NA} & \\texttt{NA}\\\\\n\\vdots & \\vdots & \\vdots\\\\\n6.18 & \\texttt{NA} & \\texttt{NA}\\\\\n\\texttt{NA} & 4.98 & \\texttt{NA}\\\\\n\\vdots & \\vdots & \\vdots\\\\\n\\texttt{NA} & 1.46 & \\texttt{NA}\\\\\n\\texttt{NA} & \\texttt{NA} & 0\\\\\n\\vdots & \\vdots & \\vdots\\\\\n\\texttt{NA} & \\texttt{NA} & 0\\\\\n\\end{bmatrix}}_{\\texttt{Y}}\n = \n\\beta_{0}\\underbrace{\\begin{bmatrix} \n1\\\\\n\\vdots\\\\\n1\\\\\n\\texttt{NA}\\\\\n\\vdots\\\\\n\\texttt{NA}\\\\\n\\texttt{NA}\\\\\n\\vdots\\\\\n\\texttt{NA}\\\\\n\\end{bmatrix}}_{\\texttt{beta.0}} + \\beta_{x}\\underbrace{\\begin{bmatrix} \n1\\\\\n\\vdots\\\\\n1000\\\\\n\\texttt{NA}\\\\\n\\vdots\\\\\n\\texttt{NA}\\\\\n\\texttt{NA}\\\\\n\\vdots\\\\\n\\texttt{NA}\\\\\n\\end{bmatrix}}_{\\texttt{beta.x}} + \\beta_{z}\\underbrace{\\begin{bmatrix} \n0.98\\\\\n\\vdots\\\\\n0.77\\\\\n\\texttt{NA}\\\\\n\\vdots\\\\\n\\texttt{NA}\\\\\n\\texttt{NA}\\\\\n\\vdots\\\\\n\\texttt{NA}\\\\\n\\end{bmatrix}}_{\\texttt{beta.z}} + \\underbrace{\\begin{bmatrix} \n\\texttt{NA}\\\\\n\\vdots\\\\\n\\texttt{NA}\\\\\n1\\\\\n\\vdots\\\\\n1000\\\\\n-1\\\\\n\\vdots\\\\\n-1000\\\\\n\\end{bmatrix}}_{\\texttt{id.x}} + \\alpha_{x,0}\\underbrace{\\begin{bmatrix} \n\\texttt{NA}\\\\\n\\vdots\\\\\n\\texttt{NA}\\\\\n\\texttt{NA}\\\\\n\\vdots\\\\\n\\texttt{NA}\\\\\n1\\\\\n\\vdots\\\\\n1\\\\\n\\end{bmatrix}}_{\\texttt{alpha.x.0}} + \\alpha_{x,z}\\underbrace{\\begin{bmatrix} \n\\texttt{NA}\\\\\n\\vdots\\\\\n\\texttt{NA}\\\\\n\\texttt{NA}\\\\\n\\vdots\\\\\n\\texttt{NA}\\\\\n0.98\\\\\n\\vdots\\\\\n0.77\\\\\n\\end{bmatrix}}_{\\texttt{alpha.x.z}}$$"
#>