Skip to content

Assignment Sample on Regression Model

This page demonstrate the assignment on regression model.

Data can be downloaded from WorldBank Open Data (URL)

screen-shot-2016-11-22-at-11-06-02

rlogo

screen-shot-2016-11-22-at-11-14-04

Sample R code on China Data

rm(list = ls())

names(china)
# dependent variable = life
# predictors = gdp, year

boxplot(china$life)
boxplot((china$life)^2)
boxplot(exp(china$life))

library(psych)
skew(china$life)
skew((china$life)^2) # best
skew(exp(china$life))

skew(china$gdp)
skew(sqrt(china$gdp))
skew(log(china$gdp))

model1 summary(model1)
plot(china$gdp, china$life)
abline(model1)

# life = 62.688 + 0.002642 * gdp
# r square = 28.49% (accuray rate)

model2 summary(model2)
plot(log(china$gdp), (china$life)^2)
abline(model2, col = "blue")

# life^2 = 211.6(ns) + 694.4*log(gdp)
# r square = 73.28%

model3 summary(model3)

anova(model2, model3)

Sample output from regression

(Life expectancy)^2 = 694.4 log(GDP per capita)

screen-shot-2016-11-22-at-11-11-15

%d bloggers like this: