2024-06-10

library(ggplot2) library(dplyr) library(plotly)

Point Estimation

In Statistics, point estimation involves the use of sample data to calculate a single value which is to serve as an estimation of an unknown population parameter. It can be used to calculate the mean or proportion of a population. A margin of error is needed to calculate confidence interval.

MOE = z\(\gamma\) \(\sqrt{\sigma^2 \div n}\)

  • MOE = margin of error
  • \(\gamma\) = quantile
  • \(\sigma\) = standard deviation
  • \(n\) = sample size

How to Calculate Point Estimate

#create data set 
data <- data.frame (
          c('Cat', 'Dog', 'Cat', 'Cat','Cat', 'Dog', 'Fish', 'Bird','Fish',
          'Dog','Bird', 'Dog', 'Cat', 'Fish','Fish', 'Cat', 'Bird', 'Bird',
          'Cat', 'Fish')

#calculate total sample size 
n <- length(data)

#calculate sum of each animal population
f <- sum(data == 'Fish')  
d <- sum(data == 'Dog')
c <- sum(data == 'Cat')
b <- sum(data == 'Bird')

#find ratio of fish to total population
p <- f/n 

print(paste("The proportion of animals who are fish is", p))

Answer to the Point Estimate Example

## [1] "The proportion of animals who are fish is 5"

Confindence Interval

The 95% confidence interval for the fish population is:

## [1] 0.0602273
## [1] 0.4397727

Number of Cats Plotly Plot

The Point Estimate of a Population Mean

The point estimate of mean is the value that estimates the mean of the sample population.

\(mean = sum\ of\ the\ terms \div number\ of\ terms\)

Mean Example

For example, let’s calculated the mean weight of a group of adults.

#data set data <- c(125, 130, 135, 140, 145,
150, 155, 160, 165, 170,
175, 180, 185, 190, 195,
200, 205, 210, 215, 220)

#calculate sample mean ans <- mean(data, na.rm = TRUE)

#print the mean weight print(paste(“The sample mean is”, ans))

Mean Calculation

## [1] "The mean weight is 172.5"

Calculating 95% Confidence Interval

We can calculate the 95% confidence interval again using the same method as prior and calculating the margin of error.

## [1] 158.6559
## [1] 186.3441

Boring ggplots

## Warning in geom_point(): All aesthetics have length 1, but the data has 20 rows.
## ℹ Please consider using `annotate()` or provide this layer with data containing
##   a single row.

Mean of Weight ggplot

## Warning in geom_point(): All aesthetics have length 1, but the data has 20 rows.
## ℹ Please consider using `annotate()` or provide this layer with data containing
##   a single row.