You are on page 1of 3

Assignment No.

2 (Course STA632)
BC220417996
SPRING 2023 (Total Marks 10)

Assignment # 2 (Topics 80-106 topics)


Question 1: Mark: 5

Write R-program for computing estimate of population mean by probability proportional to size
(PPS) sampling from the following population with k=1000.

2.2 1.5 2.1 3.2 0.6 1.3

1 2 3 4 5 6

# Population data

population <- c(2.2, 1.5, 2.1, 3.2, 0.6, 1.3)

# Population size

k <- 1000

# Calculate sampling probabilities

sampling_probabilities <- population / sum(population)

# Number of samples

n <- 100

# Perform PPS sampling

samples <- sample(population, size = n, replace = TRUE, prob = sampling_probabilities)


# Estimate of the population mean

estimated_mean <- (k / n) * sum(samples)

# Output the estimate

print(estimated_mean)

Question 2: Mark: 5

Calculate expected value for the ratio and product estimator using the following information.

Unit

1,2 11 5

1,3 13 9

1,4 12.5 7.6

2,3 16 2.4

2,4 24 9

3,4 35 24

# Data
data <- matrix(c(11, 5, 13, 9, 12.5, 7.6, 16, 2.4, 24, 9, 35, 24), ncol = 2, byrow = TRUE)

# Calculate ratios
ratios <- data[, 1] / data[, 2]

# Calculate products
products <- data[, 1] * data[, 2]

# Calculate expected value for the ratio estimator


expected_ratio <- sum(ratios) / nrow(data)

# Calculate expected value for the product estimator


expected_product <- sum(products) / nrow(data)

# Output the results


print(expected_ratio)
print(expected_product)

You might also like