# Compute counter or weight of data samples

Source:`R/compute_counter_weight.R`

`compute_counter_weight.Rd`

Computes counter (for matching approach) or weight (for weighting) approach.

## Arguments

- gps_obj
A gps object that is generated with

`estimate_gps`

function. If it is provided, the number of iteration will forced to 1 (Default: NULL).- ci_appr
The causal inference approach. Possible values are:

"matching": Matching by GPS

"weighting": Weighting by GPS

- nthread
An integer value that represents the number of threads to be used by internal packages.

- ...
Additional arguments passed to different models.

## Value

Returns a counter_weight (cgps_cw) object that includes `.data`

and `params`

attributes.

`.data`

: includes`id`

and`counter_weight`

columns. In case of`matching`

the`counter_weight`

column is integer values, which represent how many times the provided observational data was mached during the matching process. In case of`weighting`

the column is double values.`params`

: Include related parameters that is used for the process.

## Details

### Additional parameters

#### Causal Inference Approach (ci_appr)

if ci_appr = 'matching':

*bin_seq*: A sequence of w (treatment) to generate pseudo population. If`NULL`

is passed the default value will be used, which is`seq(min(w)+delta_n/2,max(w), by=delta_n)`

.*dist_measure*: Matching function. Available options:l1: Manhattan distance matching

*delta_n*: caliper parameter.*scale*: a specified scale parameter to control the relative weight that is attributed to the distance measures of the exposure versus the GPS.

## Examples

```
# \donttest{
m_d <- generate_syn_data(sample_size = 100)
gps_obj <- estimate_gps(.data = m_d,
.formula = w ~ cf1 + cf2 + cf3 + cf4 + cf5 + cf6,
gps_density = "normal",
sl_lib = c("SL.xgboost"))
cw_object <- compute_counter_weight(gps_obj = gps_obj,
ci_appr = "matching",
bin_seq = NULL,
nthread = 1,
delta_n = 0.1,
dist_measure = "l1",
scale = 0.5)
# }
```