PRACTICAL

Consider a class of 16 students taking statistics course, and their names, marks, and major subjects are given in the following table:

S. No.NameMarksMajor
1A92Maths
2B97Maths
3C68Statistics
4D62Maths
5E97Statistics
6F68Maths
7G76Statistics
8H75Statistics
9I51Maths
10J94Maths
11K70Maths
12L89Statistics
13M62Maths
14N63Maths
15O48Maths
16P97Maths

(i) Compute the following parameters:-

            (a) Population Mean

            (b) Population Variance

            (c) Population Standard Deviation

            (d) Population Mean Square Error

(ii) (a) Select an SRSWOR sample of 4 units using a random number method.

      (b) Compute the population proportion of students with a major in statistics.

      (c) Compute the variance of the estimator of population proportion.

      (d) Estimate the variance of the estimator of population proportion.

Theory-

  1. Theory of I part

Population mean is given by-

Sample mean is given by-

Population variance is given by-

Population standard deviation is given by-

Population mean square error is given by-

  1. Theory of 2nd part

Population proportion is given by-

Variance of population proportion is given by-

Estimated variance of population proportion is given by-

Where,

NA  is the number of units in the population having A characteristics and N is the total population size.

N = population size

n = sample size

QY = 1-PY

is sample proportion.

Where nA is the unit in the sample having characteristics A.

R Code-

#command to remove previous objects
rm(list=ls())
#loading and viewing data set
Student_Data = read.csv("class work 08b.csv")
View(Student_Data)

#checking the class of the dataset
data.class(Student_Data)

#loading dataset on environment
attach(Student_Data)

#population mean marks, varience,sd and population mean square error
N= length(Marks)
Mean_marks = mean(Marks)
Marks_varience = var(Marks)
Marks_sd = sd(Marks)
Marks_S = (N/(N-1))*Marks_varience
Parameter=c("Population Mean","Population Varience","Standard Deviation","Popul. Mean Sq. Error")
Calculated_Values=c(Mean_marks,Marks_varience,Marks_sd,Marks_S)

#selecting sample of size 4 with SRSWOR
n=4  #given sample size
Random_sample = sample(N,n,replace = F)
Random_sample
Logic=S..No.==Random_sample[1]|S..No.==Random_sample[2]|S..No.==Random_sample[3]|S..No.==Random_sample[4]
Sample_Data=subset(Student_Data,Logic)

#students having major as Statistics in population
Student_Data_Ststs=subset(Student_Data,Major=="Statistics")

#calculating population prop. of students having statistics as major
N_stats = length(Student_Data_Ststs$Marks)
P_Stats = N_stats/N

#calculating varience of estimator of population proportion
Q_stats = 1-P_Stats
Var_P_cap_stats = ((N-n)/(n*(N-1))) * P_Stats*Q_stats

#students having major as Statistics in sample
Sample_Data_stats = subset(Sample_Data,Sample_Data$Major=="Statistics")

#estimating varience of estimater of population prop. from obtained sample
r_stats = length(Sample_Data_stats$Marks)
p_stats = r_stats/n
q_stats = 1 - p_stats
Var_cap_P_cap_stats = ((N-n)/(N*(n-1))) * p_stats*q_stats

#Final Solutions


#Given Population Data
cat("Given population data:-\n")
data.frame(Student_Data)


#(i.)
cat("calculated Population mean, varience, s.d., and population mean square error are as follows:-\n")
data.frame(Parameter,Calculated_Values)


#(ii.) a.
cat("Selected sample data by SRSWOR is :-\n")
data.frame(Sample_Data)


#(ii.) b.
cat("Students having Statistics as major subject in the population is as follows:- \n")
data.frame(Student_Data_Ststs)
cat("population proportion of students having Statistics as major is :",P_Stats,"\n")


#(ii.) c.
cat("Calculated varience of the estimator of the population proportion is :",Var_P_cap_stats,"\n")


#(ii.) d.
cat("Number of students having Statistics as major in the obtained sample is as follows :-\n")
data.frame(Sample_Data_stats)
cat("Estimated varience of estimator of population proportion from sample is :",Var_cap_P_cap_stats,"\n")

Output From R Console (Final Solution Part)

> #Final Solutions
> 
> 
> #Given Population Data
> cat("Given population data:-\n")
Given population data:-
> data.frame(Student_Data)
   S..No. Name Marks      Major
1       1    A    92      Maths
2       2    B    97      Maths
3       3    C    68 Statistics
4       4    D    62      Maths
5       5    E    97 Statistics
6       6    F    68      Maths
7       7    G    76 Statistics
8       8    H    75 Statistics
9       9    I    51      Maths
10     10    J    94      Maths
11     11    K    70      Maths
12     12    L    89 Statistics
13     13    M    62      Maths
14     14    N    63      Maths
15     15    O    48      Maths
16     16    P    97      Maths
> 
> 
> #(i.)
> cat("calculated Population mean, varience, s.d., and population mean square error are as follows:-\n")
calculated Population mean, varience, s.d., and population mean square error are as follows:-
> data.frame(Parameter,Calculated_Values)
              Parameter Calculated_Values
1       Population Mean          75.56250
2   Population Varience         280.26250
3    Standard Deviation          16.74104
4 Popul. Mean Sq. Error         298.94667
> 
> 
> #(ii.) a.
> cat("Selected sample data by SRSWOR is :-\n")
Selected sample data by SRSWOR is :-
> data.frame(Sample_Data)
   S..No. Name Marks      Major
1       1    A    92      Maths
7       7    G    76 Statistics
11     11    K    70      Maths
12     12    L    89 Statistics
> 
> 
> #(ii.) b.
> cat("Students having Statistics as major subject in the population is as follows:- \n")
Students having Statistics as major subject in the population is as follows:- 
> data.frame(Student_Data_Ststs)
   S..No. Name Marks      Major
3       3    C    68 Statistics
5       5    E    97 Statistics
7       7    G    76 Statistics
8       8    H    75 Statistics
12     12    L    89 Statistics
> cat("population proportion of students having Statistics as major is :",P_Stats,"\n")
population proportion of students having Statistics as major is : 0.3125 
> 
> 
> #(ii.) c.
> cat("Calculated varience of the estimator of the population proportion is :",Var_P_cap_stats,"\n")
Calculated varience of the estimator of the population proportion is : 0.04296875 
> 
> 
> #(ii.) d.
> cat("Number of students having Statistics as major in the obtained sample is as follows :-\n")
Number of students having Statistics as major in the obtained sample is as follows :-
> data.frame(Sample_Data_stats)
   S..No. Name Marks      Major
7       7    G    76 Statistics
12     12    L    89 Statistics
> cat("Estimated varience of estimator of population proportion from sample is :",Var_cap_P_cap_stats,"\n")
Estimated varience of estimator of population proportion from sample is : 0.0625

Conclusion-

  • Population mean, variance, standard deviation and population mean square error are 75.56250, 280.26250, 16.74104 and 298.94667 respectively.
  •  
  • Selected random sample is-

   S..No. Name Marks      Major

1       1    A    92      Maths

7       7    G    76 Statistics

11     11    K    70      Maths

12     12    L    89 Statistics

  • Students having major subject as statistics are-

   S..No. Name Marks      Major

3       3    C    68 Statistics

5       5    E    97 Statistics

7       7    G    76 Statistics

8       8    H    75 Statistics

12     12    L    89 Statistics

  • Calculated varience of the estimator of the population proportion is : 0.04296875.
  • Estimated varience of estimator of population proportion from sample is : 0.0625.