Sunday 19 August 2018

Statistical Functions : Frequency and Partition values in R Language

Descriptive statistics:

First hand tools which gives first hand information
  • Central tendency of data
  • Variation in data
  • Structure and shape of data tendency
  • Relationship study
Graphical as well as analytical tools are used.

Absolute and relative frequencies:

Suppose there are 10 persons coded into two categories as male (M) and female (F).
   M, F, M, F, M, M, M, F, M, M,

Use a1 and a2 to refer to male and female categories.

There are 7 male and 3 female persons, denoted as n1 = 7 and n2 = 3
The number of observations in a particular category is called the absolute frequency.

The relative frequencies of a1 and a2 are
  f1 = n1/ n1 + n2
      =  7/10
      = 0.7
      = 70%
 f2  = n2/n1 + n2
      = 3/10
      = 0.3
      =  30% 
This gives us information about the propotions of male and female persons.

table (variable) create the sample frequency of the variable of the data file.

Enter data as x
table (x)   # absolute frequencies
table (x) / length (x)   # relative frequencies

Example: Code the 10 persons by using, say 1 for male (M and 2 for female (F).
          M, F, M, F, M, M, M, F, M, M 
           1,  2, 1,  2,  1,   1,  1,  2,  1,   1
> gender <-   c(1, 2, 1, 2, 1, 1, 1, 2, 1, 1)
>gender
  [1]     1 2 1 2 1 1 1 2 1 1


> table (gender)  # Absolute frequencies
 gender
   1   2
   7   3
 

> table (gender) / length (gender)   #Relative freq. gender
   1     2
 0.7   0.3





Example:

'Pizza_delivery.csv'  contains the simulated data on pizza home delivery.
  •  There are three branches (East, West, Central)  of the restaurant.
  • The pizza delivery in centrally managed over phone and delivered by one of the five drivers.
  • The data set captures the number of pizzas ordered and the final bill.
> setwd ("C: / Resource")
> pizza <- read.csv (' pizza_delivery.csv ' )


Example :

Consider data from pizza. Take first 100  values  from Direction and code Directions as 
  1. East: 1
  2. West: 2
  3. Center: 3


Partition values:

Such values divides the total frequency given data into required number of partitions.

Quartile:  Divides the data into 4 equal parts.
Decile:  Divides the data into 10 equal parts.
Percentile:  Divides the data into 100 equal parts.

quantile function computes quantiles corresponding to the given probabilities.
The smallest observation corresponds to a probability of 0 and thr largest to a probability of 1.

quantile (x, . . . .)
quantile(x, probs = seq(0, 1, 0.25, . . .)

Arguments
x           numeric vector whose sample quantile are wanted,
probs    numeric vector of probabilities with values in [0,1]. 

Example:  Marks of 15 students are



0 Comments:

Post a Comment

Popular Posts

Categories

AI (27) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (113) C (77) C# (12) C++ (82) Course (60) Coursera (176) coursewra (1) Cybersecurity (22) data management (11) Data Science (85) Data Strucures (6) Deep Learning (9) Django (6) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (5) flutter (1) FPL (17) Google (18) Hadoop (3) HTML&CSS (46) IBM (25) IoT (1) IS (25) Java (92) Leet Code (4) Machine Learning (43) Meta (18) MICHIGAN (4) microsoft (3) Pandas (3) PHP (20) Projects (29) Python (726) Python Coding Challenge (169) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (40) UX Research (1) web application (8)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses