Learn R Programming

DyadRatios (version 1.3)

boot_dr: Dyad Ratios Algorithm

Description

Estimates the Dyad Ratios Algorithm for constructing latent time series from survey-research marginals.

Value

A list with potentially two data frames `ci` has variables:

  • period: Aggregation period.

  • latent1: Estimate of latent variable from original analysis.

  • lwr: Lower confidence bound.

  • upr: Upper confidence bound.

If `pw = TRUE`, the list also contains `pw` with variables:

  • p1: Earlier period

  • p2: Later period

  • diff: (mood for p2) - (mood for p1)

  • p_diff: Probability that the larger mood is bigger than the smaller mood.

Arguments

varname

String giving the name of the input series to be smoothed. This should identify similar or comparable values in the series. Values in the series that have the same varname will be assumed to come from the same source.

date

ISO numeric representation of the date the survey was in the field (usually the start, end, or median date).

index

Numeric value of the series. It might be a percent or proportion responding in a single category (e.g., the approve response in presidential approval) or some multi-response summary. For ease of interpretation, polarity should be the same for all items.

ncases

Number of cases (e.g., sample size) of the survey. This provides differential weighting for the values. Setting this to NULL or leaving it blank will weight each value equally.

unit

Aggregation period—one of ‘D’ (daily), ‘M’ (monthly), ‘Q’ (quarterly), ‘A’ (annual), or ‘O’ (multi-year aggregation).

mult

Number of years, only used if unit is ‘O’.

begindt

Beginning date of the analysis. Defaults to earliest date in the dataset. Should be specified with lubridate::ymd().

enddt

Ending date for the analysis. Defaults to the latest date in the data.

npass

Not yet implemented.

smoothing

Logical. Specifies whether exponential smoothing is applied to the intermediate estimates during the iterative solution process. Defaults to TRUE.

endmonth

Ending month of the analysis.

R

Number of bootstrap samples.

parallel

Logical indicating whether the `mclapply` function should be used.

level

The confidence level for the intervals. Default is 0.95.

pw

Logical indicating whether to do pairwise tests.

...

Other arguments to be passed down to `mclapply`.

References

Stimson, J. A. (2018). ‘The Dyad Ratios Algorithm for Estimating Latent Public Opinion: Estimation, Testing, and Comparison to Other Approaches’, Bulletin of Sociological Methodology/Bulletin de Méthodologie Sociologique, 137–138(1), 201–218. tools:::Rd_expr_doi("10.1177/0759106318761614")

Examples

Run this code
data(jennings)
# R should be higher for real-world applications
if (FALSE) {
boot_out <- boot_dr(varname = jennings$variable, 
                  date = jennings$date, 
                  index = jennings$value, 
                  ncases = jennings$n, 
                  begindt = as.Date("1985-01-01"), 
                  enddt = max(jennings$date), 
                  npass=1, R=1000, 
                  parallel=FALSE)
boot_out
}

Run the code above in your browser using DataLab