var_y_HT | R Documentation |
Calculate the variance of the Horvitz-Thompson estimator of the mean
var_y_HT(N, n1, m_vec, y_total, pi_i_values = NULL)
N |
Population size. |
n1 |
An integer giving the initial sample size (e.g., a simple random sample). |
m_vec |
Vector of values m for the set of units in a sample, of length n1. Each m value within the vector |
y_total |
Vector of y total, each corresponding to a unique network. |
pi_i_values |
vector of inclusion probabilities, if not calculated using this function. Default is |
thompson1990adaptiveACSampling
library(ggplot2) library(magrittr) library(dplyr) # Sampling of population from Figure 1, Thompson (1990) data(Thompson1990Fig1Pop) data(Thompson1990Figure1Sample) # plot sample overlaid onto population ggplot() + geom_point(data=Thompson1990Fig1Pop, aes(x,y, size=factor(y_value), shape=factor(y_value))) + scale_shape_manual(values=c(1, rep(16, length(2:13)))) + geom_point(data=Thompson1990Figure1Sample, aes(x,y), shape=0, size=7) # INITIATE ACS Z = createACS(popdata=Thompson1990Fig1Pop, n1=dim(Thompson1990Figure1Sample)[1], initsample=Thompson1990Figure1Sample, yvar="y_value") # CALCULATE var(y_HT) # create dataframe of network info # Z_summary <- Z %>% group_by(NetworkID) %>% # summarise( # m = m[1], # y_total = sum(y_value, rm.na=TRUE) # ) %>% # dplyr::filter(NetworkID > 0) # #var_y_HT( # N = dim(Thompson1990Fig1Pop)[1], # n1 = dim(Thompson1990Figure1Sample)[1], # m = Z_summary$m, # y = Z_summary$y_total #)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.