Package: stanpop 1.0.1

Mans Magnusson

stanpop: Stan-based Poll of Polls Models

Stan Models and code to run Bayesian poll of polls models.

Authors:Mans Magnusson [aut, cre]

stanpop_1.0.1.tar.gz
stanpop_1.0.1.zip(r-4.7-any)stanpop_1.0.1.zip(r-4.6-any)stanpop_1.0.1.zip(r-4.5-any)
stanpop_1.0.1.tgz(r-4.6-any)stanpop_1.0.1.tgz(r-4.5-any)
stanpop_1.0.1.tar.gz(r-4.7-any)stanpop_1.0.1.tar.gz(r-4.6-any)
stanpop_1.0.1.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION
card.svg |card.png
stanpop/json (API)

# Install 'stanpop' in R:
install.packages('stanpop', repos = c('https://staffanbetner.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/mansmeg/stanpop/issues

Datasets:

On CRAN:

Conda:

3.38 score 2 stars 17 scripts 145 exports 53 dependencies

Last updated from:458636a6c8. Checks:9 OK. Indexed: no.

TargetResultTimeFilesSyslog
linux-develOK411
source / vignettesOK254
linux-releaseOK352
macos-releaseOK292
macos-oldrelOK259
windows-develOK333
windows-releaseOK352
windows-oldrelOK377
wasm-releaseOK165

Exports:as.polls_dataassert_stan_data_modelcollection_midpoint_datescomplete_poll_datacomplete_poll_infocomplete_poll_ycomplete_pollscompute_prediction_errorcreate_constrained_names_to_unconstrained_idx_mapcreate_unpar_one_to_one_mapcurate_swedish_pollsdiagnose_extract_min_eigen_value_Omegadivergent_transitions_percentileselpd_known_stateend_dateend_date<-end_datesend_dates<-existing_partiesextractextract_parameter_namesextract_poll_of_polls_input_argumentsextract_poll_of_polls_refit_argumentsextract_poll_of_polls_sample_argumentsextract_pop_election_periodextract_pop_empirical_posterior_mean_x_changegeom_collection_periodgeom_known_stategeom_latent_stategeom_polls_time_weightsgeom_pop_linegeom_publish_dategeom_stan_polls_dataget_adaptation_infoget_known_state_lookback_windowsget_known_state_periodsget_last_evaluation_infoget_latent_state_for_datesget_model_diagnosticsget_model_model_argumentsget_ndrawsget_num_parsget_num_uparsget_parameter_namesget_sampler_paramsget_stan_dateget_stancodeget_time_pointshouse_levelshousesincorrect_drawslatent_statelatent_state_abindlatent_state_applylatent_state_drawlatent_state_FUNlatent_state_meanlatent_state_mean_dateslatent_state_percentileslatent_state_sdlatent_state_subsetload_poplog_problogMeanExpmodel_argumentsmodel_confignn<-ndrawsparameter_block_namesparameter_block_names_from_unconstrained_indexparameter_namesparameter_names_from_unconstrained_indexparameter_unique_names_from_unconstrained_indexparameters_countsparty_levelspercentile_known_stateplot_parameters_areasplot_parameters_mcmc_hexplot_parameters_mcmc_intervalsplot_parameters_mcmc_scatterplot_poll_of_pollspoll_idpoll_id<-poll_idspoll_ids<-poll_of_pollspoll_predictive_distributionpolls_datapolls_time_reweightpolls_time_weightspolls_time_weights<-publish_datepublish_date<-publish_datespublish_dates<-recompile_stanfitreestimate_poll_of_pollsrefit_poll_of_pollsremove_file_extensionremove_known_statesrerun_poll_of_pollsRhat_is_above_mRhat_is_above_m_by_parameter_blockRhat_is_NARhat_is_NA_by_parameter_blockrmse_known_statesave_popsetup_latent_time_rangessimulate_pollsstan_polls_datastan_polls_data_modelstan_polls_data_model2stan_polls_data_model3stan_polls_data_model5stan_polls_data_model6stan_polls_data_model6bstan_polls_data_model7stan_polls_data_model8astan_polls_data_model8a1stan_polls_data_model8bstan_polls_data_model8cstan_polls_data_model8dstandard_errorstart_datestart_date<-start_datesstart_dates<-subset_datessubset_latent_state_datessubset_publish_datessubset_time_line_datessummarize_polls_time_weightstime_linetime_rangetime_range_pollstime_range<-time_ranges_are_disjointtime_scale_datestraceplotvalidate_backend_sample_argumentsx_predictyy_predicty<-

Dependencies:abindbackportsBHcallrcheckmateclicpp11descdigestdistributionaldplyrfarvergenericsggplot2gluegridExtragtableinlineisobandlabelinglifecycleloolubridatemagrittrmatrixStatsnumDerivotelpillarpkgbuildpkgconfigposteriorprocessxpsQuickJSRR6RColorBrewerRcppRcppEigenRcppParallelrlangrstanS7scalesStanHeaderstensorAtibbletidyselecttimechangeutf8vctrsviridisLitewithryaml

Readme and manuals

Help Manual

Help pageTopics
Assert that the dates are available within the time_lineassert_dates_in_time_line
Assert that the poll_data object dates are available within the time_lineassert_poll_data_in_time_line
Assert that the poll_data object dates are available within the [time_line] using time_scaleassert_poll_data_in_time_line_using_time_range assert_poll_data_in_time_line_using_time_scale
Check Stan Data for specific modelassert_stan_data_model assert_stan_data_model.model2 assert_stan_data_model.model3 assert_stan_data_model.model4 assert_stan_data_model.model5 assert_stan_data_model.model6 assert_stan_data_model.model6b assert_stan_data_model.model8a assert_stan_data_model.model8a1 assert_stan_data_model.model8a3 assert_stan_data_model.model8b assert_stan_data_model.model8c assert_stan_data_model.model8d assert_stan_data_model.model8e assert_stan_data_model.model8f assert_stan_data_model.model8g assert_stan_data_model.model8i assert_stan_data_model.model8k assert_stan_data_model.model8l assert_stan_data_model.model8m assert_stan_data_model.model9
Return indicator on polls without missing valuescomplete_polls complete_poll_data complete_poll_info complete_poll_y
Compute the default value of g_scalecompute_g_scale_default
Compute gamma parameters with same expectation and variances as a half-normal with parameter sigmacompute_gamma_parameters
Compute prediction error for a poll_of_polls modelcompute_prediction_error
Create a map between constrained parameter names and unconstrained parameter indeciescreate_constrained_names_to_unconstrained_idx_map
Semi-automatic construction of parameters for specific modelscreate_unpar_one_to_one_map
Curate the Swedish polls datasetcurate_swedish_polls
What dates are available within the time_linedates_in_time_line
Extract minimal eigen value per iterationdiagnose_extract_min_eigen_value_Omega
Extract the percentiles of the divergent transistionsdivergent_transitions_percentiles
Compute the elpd, percentiles and rmse for a true [known_state]elpd_known_state elpd_known_state.pop_model8f1 elpd_known_state.pop_model8f2 percentile_known_state rmse_known_state
Return parties existing in a given model rangeexisting_parties
Extract parameters from the stan objectextract extract.poll_of_polls
Extract refit-ready constructor arguments from a poll_of_polls objectextract_poll_of_polls_input_arguments extract_poll_of_polls_refit_arguments extract_poll_of_polls_sample_arguments
Deprecated: extract election periods from a poll_of_polls objectextract_pop_election_period
Extract mean x change from a poll_of_polls objectextract_pop_empirical_posterior_mean_x_change
Format election period lists to string for printoutformat_election_period_to_string
Format obs_x lists to string for printoutformat_obs_x_to_string
Visualize a known state in a poll_of_polls ggplotgeom_known_state
Add a [latent_state] geom to a ggplotgeom_latent_state
Compute a time period weight tibblegeom_polls_time_weights polls_time_weights polls_time_weights.polls_data polls_time_weights.stan_polls_data polls_time_weights<- polls_time_weights<-.polls_data
Visualize a stan_data objectgeom_stan_polls_data
German election datagerman_elections
German polls datagerman_polls german_polls_curated
Get adaptation infoget_adaptation_info
The first poll is the poll with the earliest starting dateget_first_poll_as_simplex
Return known-state lookback windows for a poll_of_polls objectget_known_state_lookback_windows
Return known-state evaluation periods for a poll_of_polls objectget_known_state_periods
Return the latest evaluation window for a poll_of_polls objectget_last_evaluation_info
Get the latent state for specific datesget_latent_state_for_dates
Get the model diagnostics used in a [poll_of_polls] objectget_model_diagnostics
Get the model arguments used in a [poll_of_polls] objectget_model_model_arguments
Get the number of draws/samples in a [poll_of_polls] objectget_ndraws ndraws
Get the next known state indexget_dates_next_known_state_index get_polls_next_known_state_index get_time_line_next_known_state_index
Get the number of time points between known stateget_dates_time_points_between_known_states get_polls_time_points_between_known_states get_time_line_time_points_between_known_states
Get the number of time points since the last known stateget_dates_time_points_since_last_known_state get_polls_time_points_since_last_known_state get_time_line_time_points_since_last_known_state
Get Sampler Diagnosticsget_sampler_params get_sampler_params.poll_of_polls
Extract the date when Stan was runget_stan_date
Get Stan Code from a pop objectget_stancode get_stancode.poll_of_polls
Get time line from polls or time rangeget_time_line
Get the time points for specific datesget_time_points get_time_points.poll_of_polls get_time_points.time_line
Get time points from a time line objectget_time_points_from_time_line get_total_time_points_from_time_line
Get the levels/houses from a [poll_of_polls] objecthouse_levels party_levels
Map between houses and house nameshouse_map
What samples are correct?incorrect_draws
Create a latent state objectlatent_state latent_state.poll_of_polls latent_state.stanfit
Bind latent_state objectslatent_state_abind
Apply latent_state objectslatent_state_apply
Compute an arbitrary function of latent stateslatent_state_FUN latent_state_FUN.latent_state latent_state_FUN.poll_of_polls
Compute functions of the latent statelatent_state_draw latent_state_mean latent_state_mean_dates latent_state_percentiles latent_state_sd
Subset latent_state objectslatent_state_subset
Load a poll_of_polls object saved with save_popload_pop
Stan Function for pop objectsget_num_pars get_num_upars get_num_upars.default get_num_upars.poll_of_polls log_prob log_prob.default log_prob.poll_of_polls
Extract the data when Stan was runlogMeanExp
Set default values and assert arguments for a model configurationmodel_arguments model_config
Return a data.frame with dates from a list of pop objectsmodel_dates_data_frame
Extract the parameter names and parameter counts from a poll_of_polls objectextract_parameter_names get_parameter_names parameters_counts parameter_block_names parameter_names
Get parameter names from unconstrained spaceparameter_block_names_from_unconstrained_index parameter_names_from_unconstrained_index parameter_unique_names_from_unconstrained_index
Parse a data frame of observed x (t distributed)parse_obs_x
A subset of swe_polls stored as a [polls_data] objectpd_test
Plot posterior distributions of parameterspairs.poll_of_polls plot_parameters_areas plot_parameters_mcmc_hex plot_parameters_mcmc_intervals plot_parameters_mcmc_scatter traceplot traceplot.poll_of_polls
Plot posterior distributions of parametersplot_parameters_bayesplot
Plot a [poll_of_polls] objectgeom_pop_line plot.poll_of_polls plot_poll_of_polls
Plot a [polls_data] objectgeom_collection_period geom_publish_date plot.polls_data
Get and set elements of a [data_polls] objectcollection_midpoint_dates end_date end_date<- end_dates end_dates<- houses n n<- poll_id poll_id<- poll_ids poll_ids<- publish_date publish_date<- publish_dates publish_dates<- start_date start_date<- start_dates start_dates<- y y<-
Fit a poll of polls objectpoll_of_polls
Create a [polls_data] objectas.polls_data polls_data [.polls_data
Reweights the weights based on functionpolls_time_reweight
Recompile a poll_of_polls objectrecompile_stanfit
Refit a poll_of_polls objectreestimate_poll_of_polls refit_poll_of_polls
Remove file extensionremove_file_extension
function for removing known states outside timelineremove_known_states
Rerun a poll_of_polls object without warm-start reusererun_poll_of_polls
Extract more detailed diagnostic informationRhat_is_above_m Rhat_is_above_m_by_parameter_block Rhat_is_NA Rhat_is_NA_by_parameter_block
Sample a dependent variable based on the pollssample_polls_y
Save a poll_of_polls objectsave_pop
Construct a list of [time_range]ssetup_latent_time_ranges
Simulate Pollssimulate_polls
Spanish election dataspanish_elections
Adds missing data through NA to stan datastan_data_add_missing
Generate Stan Data from [polls_data] objectsstan_polls_data stan_polls_data_model2 stan_polls_data_model3 stan_polls_data_model5 stan_polls_data_model6 stan_polls_data_model6b stan_polls_data_model7 stan_polls_data_model8a stan_polls_data_model8a1 stan_polls_data_model8b stan_polls_data_model8c stan_polls_data_model8d
Compute the posterior predictive distribution of pollsstan_polls_data_model stan_polls_data_model.model2 stan_polls_data_model.model3 stan_polls_data_model.model4 stan_polls_data_model.model5 stan_polls_data_model.model6 stan_polls_data_model.model6b stan_polls_data_model.model6c stan_polls_data_model.model7 stan_polls_data_model.model9
Compute standard errors for poll estimatesstandard_error
stanpop: Package to run Stan for poll of polls models.stanpop-package stanpop
Subset a latent state based on a time rangesubset_latent_state_dates subset_time_line_dates
Subset a [polls_data] object based on a specific [time_range]subset_dates subset_publish_dates
Subset a [polls_data] object.subset.polls_data
Summarize a polls weight object by a time linesummarize_polls_time_weights
Swedish election dataswedish_elections
Party time rangesgerman_party_time_ranges spanish_party_time_ranges swedish_party_time_ranges
Swedish polls dataswedish_polls
Spanish polls dataspanish_polls spanish_polls_curated swedish_polls_curated
Construct a time_linetime_line time_line.data.frame time_line.numeric
Expand a [time_line] object to a new time range but keep the same time point index.time_line_expand
Time rangetime_range time_range<- time_range_polls
Check if two time ranges are disjoint (not overlapping)time_ranges_are_disjoint
Convert from days to time scaletime_scale_dates
Validate backend-specific sampler argumentsvalidate_backend_sample_arguments
Compute the posterior predictive distribution of pollsx_predict x_predict.pop_model6b x_predict.pop_model6c
Four true latent states used in experimentsx_test
Compute the posterior predictive distribution of pollspoll_predictive_distribution y_predict y_predict.pop_model6b y_predict.pop_model6c