> View(Defectsafterdelivery)
> defects.old.rate<-c(Defectsafterdelivery$X2010,Defectsafterdelivery$X2011)
> defects.old.rate<-defects.old.rate[1:22]
> month.nr<-(1:22)
> defects.old.rate<-matrix(c(month.nr,defects.old.rate),ncol = 2)
> View(defects.old.rate)
> defects.old.rate.mod<-lm(defects.old.rate[,2]~defects.old.rate[,1])
> summary(defects.old.rate.mod)
Call:
lm(formula = defects.old.rate[, 2] ~ defects.old.rate[, 1])
Residuals:
Min 1Q Median 3Q Max
-14.440 -6.678 -1.944 6.976 22.572
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 817.4156 4.0677 200.952 < 2e-16 ***
defects.old.rate[, 1] 1.3354 0.3097 4.312 0.000339 ***
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 9.216 on 20 degrees of freedom
Multiple R-squared: 0.4818, Adjusted R-squared: 0.4558
F-statistic: 18.59 on 1 and 20 DF, p-value: 0.0003394
> plot(defects.old.rate[,1],defects.old.rate[,2],xlab=”month“,ylab=’Number of
Defects’)
> abline(defects.old.rate.mod.pch=2,col=“red”)
Warning message:
In int_abline(a = a, b = b, h = h, v = v, untf = untf, …) :
“defects.old.rate.mod.pch” is not a graphical parameter
> abline(defects.old.rate.mod,pch=2,col=“red”)
> library(lattice)
Warning messages:
1: In doTryCatch(return(expr), name, parentenv, handler) :
“defects.old.rate.mod.pch” is not a graphical parameter
2: In doTryCatch(return(expr), name, parentenv, handler) :
“defects.old.rate.mod.pch” is not a graphical parameter
Restarting R session
> install.packages(“lattice”)
Warning in install.packages :
cannot open URL ‘http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES.rd
s’: HTTP status was ‘404 Not Found’
Warning in install.packages :
cannot open URL ‘http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/3.4
/PACKAGES.rds’: HTTP status was ‘404 Not Found’
trying URL ‘https://cran.rstudio.com/bin/windows/contrib/3.4/lattice_0.20-35.
zip’
Content type ‘application/zip’ length 739647 bytes (722 KB)
downloaded 722 KB
package ‘lattice’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\zhoush2\AppData\Local\Temp\RtmpgFV8P9\downloaded_packages
> library(“lattice”, lib.loc=”~/R/R-3.4.0/library”)
Warning messages:
1: In doTryCatch(return(expr), name, parentenv, handler) :
“defects.old.rate.mod.pch” is not a graphical parameter
2: In doTryCatch(return(expr), name, parentenv, handler) :
“defects.old.rate.mod.pch” is not a graphical parameter
3: package ‘lattice’ was built under R version 3.4.1
> xyplot(resid(defects.old.rate.mod) ~ fitted(defects.old.rate.mod),
+ xlab=”Fitted Values”,
+ ylab=”Residuals”,
+ main=”Residual Diagnostic Plot”,
+ panel=function(x, y, …)
+ {
+ panel.grid(h=-1, v=-1)
+ panel.abline(h = 0)
+ panel.xyplot(x, y, …)
+ }
+ )
> defects.new.rate<-c(Defectsafterdelivery$X2010,Defectsafterdelivery$X2011,D
efectsafterdelivery$X2012,Defectsafterdelivery$X2013,Defectsafterdelivery$X20
14)
> month.nr<-(1:60)
> defects.new.rate<-martrix(c(month.nr,defects.new.rate),ncol = 2)
Error in martrix(c(month.nr, defects.new.rate), ncol = 2) :
could not find function “martrix”
> defects.new.rate<-matrix(c(month.nr,defects.new.rate),ncol = 2)
> View(defects.new.rate)
> plot(defects.new.rate[,1],defects.new.rate[,2])
> defects.new.rate.mod <- lm(defects.new.rate[,2] ~ defects.new.rate[,1])
> summary(defects.new.rate.mod)
Call:
lm(formula = defects.new.rate[, 2] ~ defects.new.rate[, 1])
Residuals:
Min 1Q Median 3Q Max
-114.26 -43.89 10.35 48.80 98.22
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 933.1508 15.5918 59.85 <2e-16 ***
defects.new.rate[, 1] -6.8902 0.4445 -15.50 <2e-16 ***
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 59.63 on 58 degrees of freedom
Multiple R-squared: 0.8055, Adjusted R-squared: 0.8022
F-statistic: 240.2 on 1 and 58 DF, p-value: < 2.2e16
> abline(defects.new.rate.mod,pch=2,col=“red”)
> dwtest(defects.new.rate.mod)
Error in dwtest(defects.new.rate.mod) : could not find function “dwtest”
> install.packages(“dwtest”)
Warning in install.packages :
package ‘dwtest’ is not available (for R version 3.4.0)
> View(Employeeretention)