Created
November 11, 2010 19:00
-
-
Save marutter/672989 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data <- read.csv("manhours.csv",header=T) | |
| library(MASS) | |
| library(car) | |
| library(leaps) | |
| attach(data) | |
| pairs(data) | |
| # The data concern the manpower and workload for US Navy Bachelor Officers' Quarters | |
| # Estimate manpower needs for manning Bachelor Officers Quarters. | |
| # Site: Site id | |
| # ocup: Average Daily Occupancy | |
| # check: Monthly number of check-ins | |
| # service: Weekly hours of service desk operation | |
| # sqfoot: Square feet of common area use | |
| # wings: Number of building wings | |
| # cap: Operational berthing capacity | |
| # rooms: Number of rooms | |
| # hours: Monthly man hours (The Y variable) | |
| # | |
| # Backwards Manual | |
| # | |
| boxcox(lm(hours~ocup+check+service+sqfoot+wings+cap+rooms)) | |
| summary(lm(hours~ocup+check+service+sqfoot+wings+cap+rooms)) | |
| # | |
| # Automated Stepwise | |
| # | |
| stepAIC(lm(hours~ocup+check+service+sqfoot+wings+cap+rooms,subset=c(-24))) | |
| length(hours) | |
| stepAIC(lm(hours~ocup+check+service+sqfoot+wings+cap+rooms,subset=c(-24)),k=log(24)) | |
| res <- stepAIC(lm(hours~ocup+check+service+sqfoot+wings+cap+rooms,subset=c(-24)),k=log(24)) | |
| summary(res) | |
| # | |
| # Forward | |
| # | |
| summary(lm(hours~ocup,subset=c(-24))) | |
| summary(lm(hours~check,subset=c(-24))) | |
| summary(lm(hours~service,subset=c(-24))) | |
| summary(lm(hours~sqfoot,subset=c(-24))) | |
| summary(lm(hours~wings,subset=c(-24))) | |
| summary(lm(hours~cap,subset=c(-24))) | |
| summary(lm(hours~rooms,subset=c(-24))) | |
| # | |
| # Automated | |
| # | |
| stepAIC(lm(hours~1,subset=c(-24)),scope=(~ocup+check+service+sqfoot+wings+cap+rooms),direction="forward") | |
| stepAIC(lm(hours~1,subset=c(-24)),scope=(~ocup+check+service+sqfoot+wings+cap+rooms),direction="forward",k=log(24)) | |
| stepAIC(lm(hours~1,subset=c(-24)),scope=(~ocup+check+service+sqfoot+wings+cap+rooms),direction="both",k=log(24)) | |
| # | |
| # Best subsets | |
| # | |
| res <- regsubsets(hours~ocup+check+service+sqfoot+wings+cap+rooms,data=data[-24,]) | |
| summary(res) | |
| summary(res)$bic | |
| plot(res) | |
| # | |
| # | |
| # | |
| res <- stepAIC(lm(hours~(ocup+check+service+sqfoot+wings+cap+rooms)^2,subset=c(-24)),k=log(24)) | |
| summary(lm(hours~(ocup+check+service+sqfoot+wings+cap+rooms)^2)) | |
| res <- stepAIC(lm(hours~(ocup+sqfoot+wings+cap+rooms)^2+check+service,subset=c(-24)),k=log(24)) | |
| summary(res) | |
| res <- stepAIC(lm(hours~1,subset=c(-24)),scope=(~(ocup+sqfoot+wings+cap+rooms+check+service)^2),direction="forward",k=log(24)) | |
| summary(res) | |
| ressub <- regsubsets(hours~(ocup+check+service+sqfoot+wings+cap+rooms)^2,data=data[-24,],nvmax=20) | |
| summary(ressub)$bic | |
| summary(ressub) | |
| summary(lm(hours~ocup+check+service+sqfoot+rooms+ocup:check+ocup:service+ocup:sqfoot+ocup:cap+ | |
| check:wings+check:cap+service:sqfoot+service:wings+service:cap+sqfoot:wings+ | |
| sqfoot:rooms+wings:rooms,subset=c(-24))) | |
| summary(lm(hours~ocup+check+service+sqfoot+rooms+ocup:check+ocup:service+ocup:sqfoot+ocup:cap+ | |
| check:wings+check:cap+service:wings+service:cap+sqfoot:wings+ | |
| sqfoot:room | |
| s+wings:rooms,subset=c(-24))) | |
| res<-lm(hours~check+sqfoot+rooms+ocup:service+ocup:sqfoot+ | |
| check:cap+service:cap+sqfoot:wings+ | |
| sqfoot:rooms,subset=c(-24)) | |
| summary(res) | |
| plot(res,1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment