0% found this document useful (0 votes)
76 views9 pages

Boxplot Analysis of Macroeconomic Indicators

The document provides instructions for analyzing 15 macroeconomic indicators from a Russia dataset. Key steps include: 1. Reading the dataset and removing NA values, calculating data points lost during cleaning. 2. Calculating descriptive statistics for the indicators. 3. Recoding indicators as high/low and calculating averages of other indicators. 4. Creating line charts to show trends over time for 5 indicators. 5. Calculating the intercorrelation matrix for 4 indicators. 6. Checking for outliers using boxplots and removing outlier data points.

Uploaded by

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

Boxplot Analysis of Macroeconomic Indicators

The document provides instructions for analyzing 15 macroeconomic indicators from a Russia dataset. Key steps include: 1. Reading the dataset and removing NA values, calculating data points lost during cleaning. 2. Calculating descriptive statistics for the indicators. 3. Recoding indicators as high/low and calculating averages of other indicators. 4. Creating line charts to show trends over time for 5 indicators. 5. Calculating the intercorrelation matrix for 4 indicators. 6. Checking for outliers using boxplots and removing outlier data points.

Uploaded by

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

R Assignment – 02

Identify 15 Macroeconomic Indicators of your choice from the dataset.

Ans. As per the attached document [Link]

Indicator Name
Population ages 35-39, male (% of male population)
Population ages 35-39, female (% of female population)
Population ages 30-34, male (% of male population)
Population ages 30-34, female (% of female population)
Population ages 25-29, male (% of male population)
Population ages 25-29, female (% of female population)
Population ages 20-24, male (% of male population)
Population ages 20-24, female (% of female population)
Death rate, crude (per 1,000 people)
Birth rate, crude (per 1,000 people)
Mortality rate, adult, male (per 1,000 male adults)
Mortality rate, adult, female (per 1,000 female adults)
Survival to age 65, male (% of cohort)
Survival to age 65, female (% of cohort)

1. Read the data (header should have abbreviations of economic indicators)


Ans.

Console O/P:

2. Remove the NA/missing values in the dataset-calculate the number of data points you lost while
omitting the NA values
Ans.

Before and After omitting MA values


3. Calculate the descriptive statistics of all the 15 economic indicators.
Ans.
summary(mydata1)
Console I/O:
> summary(mydata1)
[Link] [Link].5Y [Link].5Y
Min. :1960 Min. :4.959 Min. :4.361
1st Qu.:1974 1st Qu.:7.181 1st Qu.:6.512
Median :1987 Median :7.773 Median :7.013
Mean :1987 Mean :7.799 Mean :7.045
3rd Qu.:2000 3rd Qu.:8.791 3rd Qu.:7.866
Max. :2014 Max. :9.419 Max. :8.738
[Link].5Y [Link].5Y [Link].5Y
Min. : 5.298 Min. :4.494 Min. : 5.633
1st Qu.: 7.545 1st Qu.:6.622 1st Qu.: 7.645
Median : 8.382 Median :7.220 Median : 8.791
Mean : 8.254 Mean :7.128 Mean : 8.545
3rd Qu.: 9.127 3rd Qu.:7.866 3rd Qu.: 9.579
Max. :10.383 Max. :9.285 Max. :10.771

[Link].5Y [Link].5Y [Link].5Y


Min. :4.652 Min. : 5.928 Min. :4.826
1st Qu.:6.498 1st Qu.: 7.588 1st Qu.:6.402
Median :7.401 Median : 8.779 Median :7.281
Mean :7.201 Mean : 8.659 Mean :7.191
3rd Qu.:8.017 3rd Qu.: 9.708 3rd Qu.:8.040
Max. :8.897 Max. :11.560 Max. :9.293

[Link] [Link] [Link] [Link]


Min. : 8.068 Min. : 8.30 Min. :264.6 Min. :110.2
1st Qu.: 9.582 1st Qu.:10.55 1st Qu.:310.2 1st Qu.:121.4
Median :11.100 Median :14.76 Median :345.6 Median :129.6
Mean :11.745 Mean :14.06 Mean :353.0 Mean :134.7
3rd Qu.:14.200 3rd Qu.:16.00 3rd Qu.:392.9 3rd Qu.:144.0
Max. :16.400 Max. :23.79 Max. :486.3 Max. :178.4
[Link] [Link]
Min. :41.57 Min. :75.05
1st Qu.:47.37 1st Qu.:77.19
Median :52.85 Median :78.54
Mean :52.00 Mean :78.38
3rd Qu.:56.27 3rd Qu.:79.48
Max. :58.52 Max. :82.01

4. Recode any 2 economic indicators as high and low (Ex. High inflation, low inflation) and tabulate
the average value of other indicators (any 4)
Ans.
Case 1: Mortality Rate (LOW (0:350) OR HIGH)
mydata1$mortalgroup=recode([Link],'0:350="LOW";else="HIGH"')
Case 2: Mortality Rate (LESS (0:10) OR MORE)
mydata1$deathrate=recode([Link],'0:10="LESS";else="MORE"')
Average indicators:
a. Birth rate, crude (per 1,000 people)

mean([Link])

b. Survival to age 65, male (% of cohort)


mean([Link])

c. Survival to age 65, female (% of cohort)


mean([Link])

d. Survival to age 65, male (% of cohort)


mean([Link])

5. Create a line chart for 5 economic indicators and show the trend over time (Identify the
maximum and minimum years from the line chart)
Ans.
Chart 1: Death rate, crude (per 1,000 people)
plot([Link],[Link],type='l',col="blue", xlab="YEAR",ylab="Death rate"))

Chart 2: Birth rate, crude (per 1,000 people)


plot([Link],[Link],type='l',col="brown", xlab="YEAR",ylab="Birth rate"))
Chart 3: Mortality rate, adult, male (per 1,000 male adults)
plot([Link],[Link],type='l',col="brown",xlab="YEAR",ylab="Mortality rate")

Case 4: Mortality rate, adult, female (per 1,000 female adults)


plot([Link],[Link],type='l',col="RED",xlab="YEAR",ylab="Mortality rate,
FEMALE")
Case 5: Population ages 25-29, male (% of male population)
plot([Link], [Link].5Y,type='l',col="RED",xlab="YEAR",ylab="M2529")

6. Identify 4 economic indicators calculate the inter correlation matrix.


Ans.
1. Correlation between Death rate, crude (per 1,000 people) and Birth rate, crude (per 1,000
people)
> cor([Link],[Link])
[1] -0.8502126

2. Correlation between Mortality rate, adult, male (per 1,000 male adults) and Mortality rate,
adult, female (per 1,000 female adults)
> cor([Link],[Link])
[1] 0.9592079

3. Correlation between Population ages 35-39, male (% of male population) and Population ages
35-39, female (% of female population)
> cor([Link].5Y,[Link].5Y)
[1] 0.9058283

4. Correlation between Population ages 30-34, male (% of male population) AND Population
ages 30-34, female (% of female population)
> cor([Link].5Y,[Link].5Y)
[1] 0.9912934

7. Show a scatter plot for the highest correlation and interpret your results.
library(ggplot2)
qplot([Link].5Y,[Link].5Y,col="RED",xlab="YEAR",ylab="M2529")

8. Check for Outliers using BOXPLOT- All 15 economic indicators.


Ans.
[Link]([Link].5Y)$out
[Link]([Link].5Y)$out
[Link]([Link].5Y)$out
[Link]([Link].5Y)$out
[Link]([Link].5Y)$out
[Link]([Link].5Y)$out
[Link]([Link].5Y)$out
[Link]([Link].5Y)$out
[Link]([Link])$out
[Link]([Link])$out
[Link]([Link])$out
[Link]([Link])$out
[Link]([Link])$out
[Link]([Link])$out

Console O/P:
library(e1071)
> [Link]([Link])$out
numeric(0)
> [Link]([Link])$out
numeric(0)
> [Link]([Link])$out
numeric(0)
> [Link]([Link].5Y)$out
numeric(0)
> [Link]([Link].5Y)$out
[1] 4.392024 4.360909
> [Link]([Link].5Y)$out
numeric(0)
> [Link]([Link].5Y)$out
[1] 4.536185 4.494076
> [Link]([Link].5Y)$out
numeric(0)
> [Link]([Link].5Y)$out
numeric(0)
> [Link]([Link].5Y)$out
numeric(0)
> [Link]([Link].5Y)$out
numeric(0)
> [Link]([Link])$out
numeric(0)
> [Link]([Link])$out
numeric(0)
> [Link]([Link])$out
numeric(0)
> [Link]([Link])$out
[1] 178.37
> [Link]([Link])$out
numeric(0)
> [Link]([Link])$out
numeric(0)

boxplot(mydata)
9. Remove the number of data points you lost while removing outliers.
Ans.

summary([Link].5Y)
IQR=7.866-6.512
up=7.866+1.5*IQR
low=6.512-1.5*IQR

summary([Link].5Y)
IQR1=7.866-6.622
up1=7.866+1.5*IQR1
low1=6.622-1.5*IQR1

summary([Link])
IQR2=144-121.4
up2=144+1.5*IQR2
low2=121.4-1.5*IQR2

myset=subset(mydata1,[Link].5Y>low & [Link].5Y<up &


[Link].5Y>low1 & [Link].5Y < up1 & [Link] >low2 &
[Link]<up2)
10. Calculate the number of data point you lost while removing outliers.

Ans. Data points lost = 55-50 = 5 points

You might also like