# Econometrics with R for IS and Thesis [MFU MBA in LSCM]

## You are lucky!

Econometrics seem hard and tough. But with R, econometrics analysis is easy and FREE!

There are 7 more reasons why we should use R for statistics and econometrics analysis.

For the special course on Econometric analysis with R for MBA dissertation at Mae Fah Luang University, please do this 3 things as follow.

The default R interface is not that good. There is a more optimised and user-friendly IDE for R called “R Studio”. R Studio is also free and available for Window, Linux and Mac users. It is my best IDE for R in various aspects. For students, R Studio is also a good one.

## 3. Consult my online R-Manual and R related post here Please have a look and play with the ASER manual before the class, see you!

### Ex-post documents

```# codes used in the course "econometrics with R" at Mae Fah Luang University on 30th March 2013

# use R as a calculator
2+3

# start an analysis
data <- mtcars

# call variable names
names(data)

# draw a histogram
hist(data\$mpg, xlab="miles per gallon", main = "Histogram of MPG", col="blue")
hist(data\$hp, xlab="miles per gallon", main = "Histogram of hp", col="red")

# transform hp by sqr / exp
hist(sqrt(data\$hp))

# create new variable by sqrting hp
data\$sqrt_hp <- sqrt(data\$hp)

# call 2nd obs.
data[2,]
data[2:5,]
data[2:5,2]

barplot(data\$hp)

plot(data[2,])

# descriptive analysis
library("psych")
describe(data)

# Mean testing
# pair sample t-test
t.test(data\$mpg, data\$cyl)
t.test(data\$drat, data\$wt)

# independent variable t-test
t.test(data\$mpg ~ data\$am)
# regression model 1
model1 <- lm(mpg ~ gear, data = data)
summary(model1)
anova(model1)

# regression model 2
model2 <- lm(mpg ~ gear + hp, data = data)
summary(model2)
plot(model2)

# test if model2 is better than model1 statistically
anova(model1, model2)
<pre>```