Statistics is the study of how to collect, analyze, and draw conclusions from data. It’s a hugely valuable tool that you can use to bring the future into focus and infer the answer to tons of questions. For example, what is the likelihood of someone purchasing your product, how many calls will your support team receive, and how many jeans sizes should you manufacture to fit 95% of the population? In this course, you’ll use sales data to discover how to answer questions like these as you grow your statistical skills and learn how to calculate averages, use scatterplots to show the relationship between numeric values, and calculate correlation. You’ll also tackle probability, the backbone of statistical reasoning, and learn how to conduct a well-designed study to draw your own conclusions from data.
Summary statistics gives you the tools you need to boil down massive datasets to reveal the highlights. In this chapter, you’ll explore summary statistics including mean, median, and standard deviation, and learn how to accurately interpret them. You’ll also develop your critical thinking skills, allowing you to choose the best summary statistics for your data.
there are five different measurement used in descriptive statistics namely;
we will compute all of the above measurements using different R packages as follows ;
library(survival)
data("cancer")
# how to know structure of the dataset
str(lung)
## 'data.frame': 228 obs. of 10 variables:
## $ inst : num 3 3 3 5 1 12 7 11 1 7 ...
## $ time : num 306 455 1010 210 883 ...
## $ status : num 2 2 1 2 2 1 2 2 2 2 ...
## $ age : num 74 68 56 57 60 74 68 71 53 61 ...
## $ sex : num 1 1 1 1 1 1 2 2 1 1 ...
## $ ph.ecog : num 1 0 0 1 0 1 2 2 1 2 ...
## $ ph.karno : num 90 90 90 90 100 50 70 60 70 70 ...
## $ pat.karno: num 100 90 90 60 90 80 60 80 80 70 ...
## $ meal.cal : num 1175 1225 NA 1150 NA ...
## $ wt.loss : num NA 15 15 11 0 0 10 1 16 34 ...
#?lung
# how to see the first six row of the dataset
head(lung)
# how to select one variable in the dataset
time<-lung$time
# descriptive statistics
mean(time)
## [1] 305.2325
median(time)
## [1] 255.5
mode(time)
## [1] "numeric"
sd(time)
## [1] 210.6455
var(time)
## [1] 44371.54
max(time)
## [1] 1022
min(time)
## [1] 5
library(psych)
describe(time)
library(EnvStats)
## Warning: package 'EnvStats' was built under R version 4.4.0
##
## Attaching package: 'EnvStats'
## The following objects are masked from 'package:stats':
##
## predict, predict.lm
summaryFull(time)
## time
## N 228
## Mean 305.2
## Median 255.5
## 10% Trimmed Mean 281.1
## Geometric Mean 226.5
## Skew 1.094
## Kurtosis 0.9401
## Min 5
## Max 1022
## Range 1017
## 1st Quartile 166.8
## 3rd Quartile 396.5
## Standard Deviation 210.6
## Geometric Standard Deviation 2.477
## Interquartile Range 229.7
## Median Absolute Deviation 160.9
## Coefficient of Variation 0.6901
library(AdequacyModel)
descriptive(time)
## $mean
## [1] 305.2325
##
## $median
## [1] 255.5
##
## $mode
## [1] 163 11
##
## $variance
## [1] 44371.54
##
## $Skewness
## [1] 1.08679
##
## $Kurtosis
## [1] 0.89344
##
## $minimum
## [1] 5
##
## $maximum
## [1] 1022
##
## $n
## [1] 228
to present a numerical data , we will introduce 8 most common plots and graphs namely ;
boxplot(time)
boxplot(time,col= "red",xlab="time",ylab= "numberof patients",
main="Survival Data for lung cancer patients")
hist(time)
hist(time,col= "green",xlab="time",ylab= "numberof patients",
main="Survival Data for lung cancer patients")
plot(density(time))
plot (density(time),col= "green",xlab="time",ylab= "numberof patients",
main="Survival Data for lung cancer patients")
plot(density(time))
polygon(density(time),col="cyan", border = "black")