rpl_se: Calculate standard errors for parameters estimated with the...

View source: R/functions.R

rpl_seR Documentation

Calculate standard errors for parameters estimated with the RPL

Description

Calculate standard errors for parameters estimated with the RPL

Usage

rpl_se(
  mydata,
  parameters,
  pi,
  offsets = NULL,
  block_indices = NULL,
  verbose = FALSE
)

Arguments

mydata

Data matrix

parameters

Vector providing estimated values for all parameters (means followed by correlations)

pi

Bernoulli sampling parameter (0 < pi <= 1)

offsets

If needed, a matrix of offsets (optional)

block_indices

List of vectors providing indices for each block for blockwise exchangeable correlation matrices

verbose

If TRUE, include verbose output

Value

A named list containing the following:

  • se - standard errors for each estimated parameter

  • parameters - user-provided estimated parameter values

  • S - estimated S matrix

  • Sinv - estimated S^(-1) matrix

References

Mazo, G., Karlis, D., Rau, A. (2021) A randomized pairwise likelihood method for complex statistical inferences. In revision. hal-03126621.

Examples


## 1) Simulate exchangeable correlation matrix ---------------------------------
d <- 10
sim_exchangeable <-
    simulate_mvt_poisson(n = 1000, d = d,
                         param = list(margins = rep(1, d), disp = 0.5),
                         type = "exchangeable")

init_exchangeable <- init(sim_exchangeable$data, type = "exchangeable")
run_exchangeable <- rpl_optim(init_exchangeable, sim_exchangeable$data, pi = 0.1)

## 2) Simulate unstructured correlation matrix ---------------------------------
d <- 4
sim_unstructured <-
    simulate_mvt_poisson(n = 1000, d = d,
                         param = list(margins = rep(1, d),
                                      disp = c(0.4,0.5,0.6,0.7,0.8,0.9)),
                         type = "unstructured")

init_unstructured <- init(sim_unstructured$data, type = "unstructured")
run_unstructured <- rpl_optim(init_unstructured, sim_unstructured$data, pi = 0.1)

## Calculate SE of estimated parameters
se_unstructured <- rpl_se(mydata=sim_unstructured$data,
                          parameters=run_unstructured$par,
                          pi = 0.1,
                          offsets=NULL, verbose=FALSE)


## 3) Simulate one-factor correlation matrix -----------------------------------
d <- 4
sim_factor <-
    simulate_mvt_poisson(n = 1000, d = d,
                         param = list(margins = rep(1, d),
                                      disp = seq(0, 1, length = d)),
                         type = "factor")

init_factor <- init(sim_factor$data, type = "factor")
run_factor <- rpl_optim(init_factor, sim_factor$data, pi = 0.1)

## Calculate SE of estimated parameters
se_factor <- rpl_se(mydata=sim_factor$data,
                          parameters=run_factor$par,
                          pi = 0.1,
                          offsets=NULL, verbose=FALSE)

## 4) Simulate block-exchangeable correlation matrix ---------------------------
d <- 10
block_indices <- list(c(1:5), c(6:10))
sim_block <-
    simulate_mvt_poisson(n = 1000, d = d,
                         block_indices = block_indices,
                         param = list(margins = rep(1, d),
                                      disp = c(0.5,0.1,0.8)),
                         type = "block_exchangeable")

init_block<- init(sim_block$data, type = "block_exchangeable",
                  block_indices = block_indices)
run_block <- rpl_optim(init_block, sim_block$data, pi = 0.1,
                       block_indices = block_indices)

andreamrau/rpl documentation built on April 26, 2023, 3:57 p.m.