Example Of Colnames(Ldc) Essay
# Assignment #10 - Factors and dummy variables
# Dataset LDC.csv
# This dataset was used in the analysis of the effect
# of size of the Local Distribution Company (LDC)
# on cost of electricity in Ontario
# Variables
# X = community
# Customers = number of customers
# OMandA = Operating and Maintenance Costs
# Dist.Cost = distribution cost (cost of power
# to the company)
# Total.Bill + average total bill
#
# Student number 297127
#################################################
# load data
d <- file.choose()
LDC<- as.data.frame(read.csv(d, row.names=NULL),header=T, row.names=NULL)
LDC
# Student number 297127
a <- 29
b <- 71
c <- 27
# none is greater than 72
# delete observations:
Delete <- c(a,b,c)
LDC <- LDC[-Delete,]
# plots:
par(mfrow=c(2,1))
plot(LDC$Area, LDC$OMandA,
ylab = "OMandA",
xlab = "Area (N = North, S = South)")
plot(LDC$Size, LDC$OMandA,
ylab = "OMandA",
xlab = "Size (S = Small, M = Medium, L = Large, XL = Extra Large)")
# are there any significant differences?
var.test(LDC$OMandA ~ LDC$Area) # different variances
t.test(OMandA ~ Area, data = LDC) #p.value 0.00571
kruskal.test(OMandA ~ Size, data = LDC) #p.value 1.053e-05
# regress OMandA on Area
model1 <- lm(OMandA ~ Area, data = LDC)
summary(model1)
# regress Total.Bill on Customers, OMandA, and Area
model2 <- lm(Total.Bill ~ Customers + OMandA + Area, data = LDC)
summary(model2)
# add interaction:
model3 <- lm(Total.Bill ~ Customers + OMandA + Area + OMandA:Area, data = LDC)
summary(model3)
# bonus marks
install.packages("effects")
library(effects)
M <- lm(Total.Bill ~ Size:OMandA, data = LDC)
summary(M)
plot(allEffects(M))
plot(allEffects(M), multiline=T)
#####################
### END OF SCRIPT ###
#####################
- APA
- MLA
- Harvard
- Vancouver
- Chicago
- ASA
- IEEE
- AMA