0% found this document useful (0 votes)
41 views3 pages

R Programming for PPS Sampling

This document contains instructions for Assignment #2 of Course STA632 for Spring 2023. It includes two questions worth 5 marks each. Question 1 involves writing an R program to compute the estimate of a population mean using probability proportional to size (PPS) sampling. Question 2 calculates the expected value of ratio and product estimators using sample data provided.

Uploaded by

Tatton Jody
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views3 pages

R Programming for PPS Sampling

This document contains instructions for Assignment #2 of Course STA632 for Spring 2023. It includes two questions worth 5 marks each. Question 1 involves writing an R program to compute the estimate of a population mean using probability proportional to size (PPS) sampling. Question 2 calculates the expected value of ratio and product estimators using sample data provided.

Uploaded by

Tatton Jody
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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