## Question

## Transcribed Text

## Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

var_fun_alt <- function(y, x){# Calculating probabilities ie. p

p = x/sum(x)

# Finding unique values from x

v = length(unique(x))

# Finding total number of observations

N = length(y)

# Taking v samples from the overall data

sa = sample(1:N, v, replace = TRUE, prob =p )

# Taking pi only of samples

p_sa = p[sa]

# Taking y values of samples

y_sa = y[sa]

# Calculating pi ie. pi = 1 - (1-p)^n

pii = 1 - (1 - p_sa)^v

# Unbiased estimator of tau

tauh = sum(y[sa]/p[sa])

# Calculating t = v*y/pi

t = v * y_sa/pii

# Finding st^2 using the formula i.e. [1/(v-1)]* sum((t-pi)^2)

s_t2 = (1/(v-1)) * sum((t-pii)^2)

# The alternative variance estimator is

vhat = ((N-v)/N) * s_t2/v

# Returning results

res=c(est=tauh,varh=vhat)

res

}

var_fun <- function(y, x) {

# Calculating probabilities ie. pi

p = x/sum(x)

# Finding unique values from x

v = length(unique(x))

# Finding total number of observations

N = length(y)

# Taking v samples from the overall data

sa = sample(1:N, v, replace = TRUE, prob =p )

# Taking pi only of samples

p_sa = p[sa]

# Taking y values of samples

y_sa = y[sa]

# Calculating pi ie. pi = 1 - (1-p)^n

pii = 1 - (1 - p_sa...

By purchasing this solution you'll be able to access the following files:

solution.R.