DSC_per: Permutation

Description Usage Arguments Value Examples

View source: R/DSC_per.R

Description

Function for evaluating the significance of the estimates using permutation distributions

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
DSC_per(
  c_df,
  t_df,
  T0,
  M = 100,
  solver = "SCS",
  ww = 0,
  peridx = 0,
  evgrid = seq(from = 0, to = 1, length.out = 101),
  graph = TRUE,
  y_name = "y",
  x_name = "x"
)

Arguments

c_df

a list of list: each sublist contains observations of every control units at a specific time period. e.g. c_df[[1]][[2]] contains the observations of the second control unit at the first time period.

t_df

a list of observations. e.g. t_df[[1]] contains the observations of the target at the first time period.

T0

an integer specifying the end of pre-treatment period.

M

an integer specifying the number of draws from the uniform distribution for approximating the integral.

solver

a solver for the optimization problem; see installed_solvers in CVXR for more options.

ww

0 or a vector. By default, i.e. 0, arithmetic mean is used for calculating optimal weights. Otherwise, a vector of specific weights is used.

peridx

0 or a vector. By default, i.e. 0, all control units will be used for the permutation. Otherwise, a vector of specific control units will be used.

evgrid

a vector of gridpoints used to evaluate quantile functions.

graph

TRUE/FALSE, indicating whether to output a plot of squared Wasserstein distances.

y_name

a string for the title of the y-axis.

x_name

a string for the title of the x-axis.

Value

DSC_per returns a list containing the following components:

target.dist

a vector of squared Wasserstein distances calculated using original target and control units.

control.dist

a list of squared Wasserstein distances calculated using permutation distributions.

Examples

1
2
3
4
5
6
7
#simulated data from independent normal distributions
#ex_normal() calls the simulated data
#detail can be found by ??ex_normal
#all control units are used
DSC_per(c_df=ex_normal()$control, t_df=ex_normal()$target, T0=5, M=100, solver="SCS", ww=0, peridx=0, evgrid=seq(from=0, to=1, length.out=1001), graph=TRUE, y_name='y', x_name='x')
#the first, third and fifth control units are used
DSC_per(c_df=ex_normal()$control, t_df=ex_normal()$target, T0=5, M=100, solver="SCS", ww=0, peridx=c(1,3,5), evgrid=seq(from=0, to=1, length.out=1001), graph=TRUE, y_name='y', x_name='x')

hesyserena/DSC documentation built on Dec. 20, 2021, 3:49 p.m.