# SPEW Framework for Generating Synthetic Ecosystems

## Documentation for package ‘spew’ version 1.3.0

- DESCRIPTION file.
- User guides, package vignettes and other documentation.

## Help Pages

A B C D E F G H I M O P R S T U V W

spew-package | spew: an R package for generating synthetic ecosystems

## -- A --

add_characteristic | Add a characteristic to an existing population
add_char_demo | Add characteristic by matching on demographics
align_pums | Match the pums variables with marginal totals
allocate_count | Re-allocate excess counts to other locations
assign_place | Assign a place to a person
assign_place_coords | Assign a place with long/lat coords to a synthetic population
assign_schools | Assign schools to a synthetic population.
assign_schools_inner | Function which assigns schools
assign_weights | Assign weights for ipf-based sampling
assign_workplaces | Assign an ESRI workplace to synthetic population
assign_workplaces_inner | Function which assigns workplaces

## -- B --

base_map_theme | The base map theme for SPEW

## -- C --

calc_dists | Calculate distance b/w cont table row and pums
call_spew | Wrapper for reading, formatting, and writing SPEW ecosystems
cap_default | How to weight the capacities of of school.
ccount | Adjust number of households
checkDF | Check if df is in the right format
check_logfile | Check to see if a SPEW log-file is complete
check_path | Check the path to output to run diags
check_place_ids | Check the Place ID's match
check_pop_table | Check the pop_table has all the necessary components
check_puma_ids | Check the puma id's match
check_pums | Check that the pums has all the required components
check_shapefile | Check the shapefile has the necessary components
check_var_names | Check to see if variable names are in SPEW outputs
clean_names | Remove whitespace, capitals, and non ASCII
combine_counts | Combine two rows of a pop_table into one
create_column | Parse a SPEW Log-file to into an appropriate column

## -- D --

delaware | Input data for Keny County, Delaware
demo_sample | Sample extra characteristics from char pums and add them to the pop df

## -- E --

euclidean_dist | Get the euclidean distance between two points (x1, y1) and (x2, y2)
extract_st_co_tr | Extract the state, county, and tract ID from a string
extrapolate_probs_to_pums | Take unique probabilites for table and spread them to rest of PUMS
extrapolate_probs_to_pums_joint | Take unique probabilites for table and spread them to rest of PUMS

## -- F --

fill_cont_table | Fill marginal contingency with ipf
fips_to_name | Translate FIPS number to place name
format_data | Format data before entering make

## -- G --

get_base_map | Get the base map for plotting
get_centers | Get the center longitude and latitude for each region
get_coords_scaled | Getting a plotting data frame
get_data_group | Extract data-group from location name
get_dfs | Get the dataframes from SPEW summary output
get_dists | Get the distances between the schools and the people.
get_dist_mat | Get the distance matrix
get_envs | Gather the unique assignments for the region
get_filenames | Get the filenames of the SPEW output, separated by the level
get_header | Extract the header from a population
get_level | Obtain the correct level for ipums data
get_pop_totals | Get the population totals from a summarized SPEW region
get_rows | Extract rows with a certain character
get_shapefile_indices | Obtain the shapefile indices corresponding to the pop table
get_targets | Obtain the target marginals for IPF
get_total_time | Extract the total run-time from a SPEW log-file
get_weight_dists | Weight place assignment probabilities

## -- H --

haversine | Get the haversine distance between two points (x1, y1) and (x2, y2) scaled between 0 and 1.
haversine_dist | Get the haversine distance between two points (x1, y1) and (x2, y2) scaled between 0 and 1.

## -- I --

impute_missing_vals | Impute Missing Values in a data frame

## -- M --

make_ipf_obj | Set up for creating a set of marginal information for IPF sampling
make_mm_obj | Make moment matching object
merge_reduce | Wrapper function for merge

## -- O --

organize_summaries | Organize the summaries into a more palatable format

## -- P --

people_to_households | Convert a population count to household count
plot_agents | Plot the agents of synthetic ecosystem
plot_bds | Plot the boundaries of the synthetic ecosystem
plot_characteristic_proportions | Plot characteristic summary output from summarize_top_spew_region
plot_env | Plot the environments of the synthetic ecosystem
plot_interior | Plot the interior of the synthetic ecosystem
plot_labs | Add the labels and the theme to the plot
plot_pop_totals | Plot characteristic summary output from summarize_top_spew_region as totals
plot_region | Plot SPEW region
plot_roads | Plot the roads of the synthetic ecosystem
plot_syneco | Plot Synthetic Ecosystem
print_region_list | Write out information on each region

## -- R --

read_data | Read SPEW input data from files
read_marginals | Read in the marginals population characteristic totals
read_moments | Read in the R data object for moment matching
read_pop_table | Read in the population counts
read_roads | Read in road lines shapefiles
read_shapespatial_to_ogr | Read in shapefile using readOGR
remove_count | Remove a row from the pop_table
remove_excess | Remove comma's, accents, etc. from name
remove_holes | Remove holes from an object of class Polygon
remove_words | Remove excess words
replace_word | Replace an existing word

## -- S --

sample_households | Sample appropriate indices from household PUMS
sample_ipf | Sample households PUMS accoording to IPF
sample_locations | Generic sampling locations function
sample_locations_roads | Sample coordinates from roads
sample_locations_uniform | Sample from a particular polygon shapefile
sample_mm | Sample households PUMS according to MM
sample_people | Sample from the individual person PUMS data frame
sample_uniform | Sample households uniformly
sample_with_cont | Sample from pums
samp_roads | Sample the locations from a SpatialLines object
solve_mm_for_joint | Do the Moment Matching solving for joint distribution
solve_mm_for_var | Do the MM solving for an individual variable
solve_mm_weights | Weight the records of the PUMS so the averages in mm_df will be obtained
spew | SPEW algorithm to generate synthetic ecosystems
spewlog_to_df | Convert a SPEW Logfile into a data-frame
spew_mc | Run SPEW in Parallel with a Multicore backend
spew_mpi | Run SPEW in Parallel with an MPI backend
spew_place | Generate synthetic ecosystem for single place
spew_seq | Run SPEW Sequentially
spew_sock | Run SPEW in Parallel with a SOCK backend
standardize_pop_table | Make sure pop_table has the appropriate columns
subset_pums | Align pums with marginal totals
subset_schools | Subset the schools to that of the county
subset_shapes_roads | Subset the shapefile and road lines to proper roads within specified tract
summarize_environment | Return the unique environment assignments in a region
summarize_features | Summarize individual features of a region
summarize_spew | Summarize a SPEW region
summarize_spew_out | Summarize spew output
summarize_spew_region | Summarize a singular region from spew output
summarize_syneco | Summarize synthetic ecosystem for SPEW console output
summarize_top_region | Summarize the region in a more human-readable format

## -- T --

tartanville | Input data for Tartanville

## -- U --

update_freqs | Update frequencies to match # of households
uruguay | Input data for Uruguay
us | Table of US states and counties
us_pums_sf | An example marginal distribution table

## -- V --

verify_column | Verify the column is the correct size

## -- W --

weight_dists | Weight school assignment probabilities
weight_dists2 | Weight school assignment probabilities
weight_dists_C | Weight school assignment probabilities by capacity only
weight_dists_D | Weight school assignment probabilities, distance only
write_data | Output our final synthetic populations as csv's
write_pop_table | Write out the final, formatted table
write_schools | Write school environment
write_workplaces | Write workplaces environment