[R] to create a fuction for removing outlier
PIKAL Petr
petr.pikal at precheza.cz
Tue Dec 30 11:55:20 CET 2014
Hi
Without going to deeply to your code; your data seems to be numeric, but for some reason you read them as character. You shall consult read.csv help and your original data. They probably have some feature which prevent them to be read correctly.
To your question, what you want can be achieved by while loop.
something like this
while (abs(studres(object))>3) {
ms <-max(abs(studres(object)))
del <- which(ms== abs(studres(object)))
#do fitting with del removed from data
#save the fit
}
you can also use rstudent(object)
Cheers
Petr
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of
> Methekar, Pushpa (GE Transportation, Non-GE)
> Sent: Tuesday, December 30, 2014 9:44 AM
> To: r-help at r-project.org
> Subject: [R] to create a fuction for removing outlier
>
> Hi all,
> Thanks for your support. sorry for inconvenience cause due to lack of
> information. here is my all r- program .
>
>
> #### read in data
> raw=read.csv(file.choose(),header = T, stringsAsFactors=FALSE)
>
> str(raw)
>
> ####conversion from factor to numeric of xs raw$Engine.Speed <-
> as.numeric(raw$Engine.Speed)
> raw$Engine.Power<- as.numeric(raw$Engine.Power) raw$Diesel.LHV <-
> as.numeric(raw$Diesel.LHV) raw$NG.LHV <- as.numeric(raw$NG.LHV)
> raw$Compressor.Inlet.Temperature <-
> as.numeric(raw$Compressor.Inlet.Temperature)
> raw$Int.Mfld.Temp<- as.numeric(raw$Int.Mfld.Temp)
> raw$Cmd.Advance.Angle<- as.numeric(raw$Cmd.Advance.Angle)
> raw$Cmd.Fuel.Rail.Press.Manual<-
> as.numeric(raw$Cmd.Fuel.Rail.Press.Manual)
> raw$X..NG.by.Energy<- as.numeric(sub("%","",raw$X..NG.by.Energy))/100
>
>
> ####conversion from factor to numeric of Ys raw$Pre.Turb.Temp.L <-
> as.numeric(raw$Pre.Turb.Temp.L) raw$Avg.PCP <- as.numeric(raw$Avg.PCP)
> raw$BSHC <- as.numeric(raw$BSHC) raw$BSCO <- as.numeric(raw$BSCO)
> raw$GETS.cBSNOx <- as.numeric(raw$GETS.cBSNOx) raw$Avg.COV.GIMEP <-
> as.numeric(raw$Avg.COV.GIMEP) raw$Intake.Manifold.Pressure <-
> as.numeric(raw$Intake.Manifold.Pressure)
> raw$Emiss..1..EPA.MAF..Dry. <-
> as.numeric(sub(",","",raw$Emiss..1..EPA.MAF..Dry.))
> raw$Turbo.Speed <- as.numeric(raw$Turbo.Speed)
>
>
> #### create a matrix plot of scatter plot
> xs=raw[c("Engine.Speed","X..NG.by.Energy","Int.Mfld.Temp","Cmd.Advance.
> Angle","Engine.Power","Cmd.Fuel.Rail.Press.Manual","Compressor.Inlet.Te
> mperature","Diesel.LHV","NG.LHV")]
>
> ys=raw[c("Pre.Turb.Temp.L","Avg.PCP","BSHC","BSCO","GETS.cBSNOx","Avg.C
> OV.GIMEP","Turbo.Speed","Intake.Manifold.Pressure","Emiss..1..EPA.MAF..
> Dry.")]
> pairs(xs,main="x's")
> pairs(ys,main="y's")
>
> ### calculate correlation coefficient
> xs[is.na(xs)] <- 0 #replace all NA with 0
> cor(xs)
> ys[is.na(ys)] <- 0 #replace all NA with 0
> cor(ys)
> cor(xs,ys,method = "spearman")
> pairs(xs,ys)
> save.image(file="plotting.RData")
>
>
> ## make data frame of x's and y's
> xsys=data.frame(xs,ys)
>
> library(MASS)
> #### first order multiple linear regression fitted.modely1.temp.l <-
> rlm(
> Pre.Turb.Temp.L~X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.
> Power+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LH
> V+NG.LHV,data=xsys)
>
> fitted.modely2.avg.pcp <- rlm(
> Avg.PCP~X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+Cm
> d.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+NG.LHV
> ,data=xsys)
>
> fitted.modely3.bshc <- rlm(
> BSHC~X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+Cmd.F
> uel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+NG.LHV,da
> ta=xsys)
>
> fitted.modely4.bsco <-
> rlm(BSCO~X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+C
> md.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+NG.LH
> V,data=xsys)
>
> fitted.modely5.gets <-
> rlm(GETS.cBSNOx~X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.
> Power+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LH
> V+NG.LHV,data=xsys)
>
> fitted.modely6.gimep <-
> rlm(Avg.COV.GIMEP~X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engin
> e.Power+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.
> LHV+NG.LHV,data=xsys)
>
> fitted.modely7.ts <- rlm( Turbo.Speed
> ~X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+Cmd.Fuel.
> Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+NG.LHV,data=x
> sys)
>
> fitted.modely8.imp <- rlm(Intake.Manifold.Pressure
> ~X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+Cmd.Fuel.
> Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+NG.LHV,data=x
> sys)
>
> fitted.modely9.maf <- rlm( Emiss..1..EPA.MAF..Dry.
> ~X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+Cmd.Fuel.
> Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+NG.LHV,data=x
> sys)
>
>
>
> #### comlete second order multiple linear regression
> secfitted.modely1.temp.l<-lm(Pre.Turb.Temp.L
> ~poly(Engine.Speed,2)+poly(X..NG.by.Energy,2)+poly(Int.Mfld.Temp,2)+pol
> y(Cmd.Advance.Angle,2)+poly(Engine.Power,2)+poly(Cmd.Fuel.Rail.Press.Ma
> nual,2)
>
> +poly(Compressor.Inlet.Temperature,2)+poly(Diesel.LHV,2)+poly(NG.LHV,2)
>
> +Engine.Speed*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +X..NG.by.Energy*(Engine.Speed+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Int.Mfld.Temp*(X..NG.by.Energy+Engine.Speed+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Advance.Angle*(X..NG.by.Energy+Int.Mfld.Temp+Engine.Speed+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Engine.Power*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.S
> peed+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Fuel.Rail.Press.Manual*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.
> Angle+Engine.Power+Engine.Speed+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Compressor.Inlet.Temperature*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advanc
> e.Angle+Engine.Power+Cmd.Fuel.Rail.Press.Manual+Engine.Speed+Diesel.LHV
> +NG.LHV)
>
> +Diesel.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Pow
> er+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Engine.Speed
> +NG.LHV)
>
> +NG.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+C
> md.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+Engin
> e.Speed),data=xsys)
>
> secfitted.modely2.avg.pcp<-lm(Avg.PCP
> ~poly(Engine.Speed,2)+poly(X..NG.by.Energy,2)+poly(Int.Mfld.Temp,2)+pol
> y(Cmd.Advance.Angle,2)+poly(Engine.Power,2)+poly(Cmd.Fuel.Rail.Press.Ma
> nual,2)
>
> +poly(Compressor.Inlet.Temperature,2)+poly(Diesel.LHV,2)+poly(NG.LHV,2)
>
> +Engine.Speed*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +X..NG.by.Energy*(Engine.Speed+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Int.Mfld.Temp*(X..NG.by.Energy+Engine.Speed+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Advance.Angle*(X..NG.by.Energy+Int.Mfld.Temp+Engine.Speed+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Engine.Power*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.S
> peed+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Fuel.Rail.Press.Manual*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.
> Angle+Engine.Power+Engine.Speed+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Compressor.Inlet.Temperature*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advanc
> e.Angle+Engine.Power+Cmd.Fuel.Rail.Press.Manual+Engine.Speed+Diesel.LHV
> +NG.LHV)
>
> +Diesel.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Pow
> er+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Engine.Speed
> +NG.LHV)
>
> +NG.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+C
> md.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+Engin
> e.Speed),data=xsys)
>
> secfitted.modely3.bshc<-lm( BSHC
> ~poly(Engine.Speed,2)+poly(X..NG.by.Energy,2)+poly(Int.Mfld.Temp,2)+pol
> y(Cmd.Advance.Angle,2)+poly(Engine.Power,2)+poly(Cmd.Fuel.Rail.Press.Ma
> nual,2)
>
> +poly(Compressor.Inlet.Temperature,2)+poly(Diesel.LHV,2)+poly(NG.LHV,2)
>
> +Engine.Speed*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +X..NG.by.Energy*(Engine.Speed+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Int.Mfld.Temp*(X..NG.by.Energy+Engine.Speed+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Advance.Angle*(X..NG.by.Energy+Int.Mfld.Temp+Engine.Speed+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Engine.Power*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.S
> peed+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Fuel.Rail.Press.Manual*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.
> Angle+Engine.Power+Engine.Speed+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Compressor.Inlet.Temperature*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advanc
> e.Angle+Engine.Power+Cmd.Fuel.Rail.Press.Manual+Engine.Speed+Diesel.LHV
> +NG.LHV)
>
> +Diesel.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Pow
> er+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Engine.Speed
> +NG.LHV)
>
> +NG.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+C
> md.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+Engin
> e.Speed),data=xsys)
>
>
> secfitted.modely4.bsco<-lm( BSCO
> ~poly(Engine.Speed,2)+poly(X..NG.by.Energy,2)+poly(Int.Mfld.Temp,2)+pol
> y(Cmd.Advance.Angle,2)+poly(Engine.Power,2)+poly(Cmd.Fuel.Rail.Press.Ma
> nual,2)
>
> +poly(Compressor.Inlet.Temperature,2)+poly(Diesel.LHV,2)+poly(NG.LHV,2)
>
> +Engine.Speed*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +X..NG.by.Energy*(Engine.Speed+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Int.Mfld.Temp*(X..NG.by.Energy+Engine.Speed+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Advance.Angle*(X..NG.by.Energy+Int.Mfld.Temp+Engine.Speed+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Engine.Power*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.S
> peed+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Fuel.Rail.Press.Manual*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.
> Angle+Engine.Power+Engine.Speed+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Compressor.Inlet.Temperature*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advanc
> e.Angle+Engine.Power+Cmd.Fuel.Rail.Press.Manual+Engine.Speed+Diesel.LHV
> +NG.LHV)
>
> +Diesel.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Pow
> er+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Engine.Speed
> +NG.LHV)
>
> +NG.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+C
> md.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+Engin
> e.Speed),data=xsys)
>
>
>
> secfitted.modely5.gets<-lm( GETS.cBSNOx
> ~poly(Engine.Speed,2)+poly(X..NG.by.Energy,2)+poly(Int.Mfld.Temp,2)+pol
> y(Cmd.Advance.Angle,2)+poly(Engine.Power,2)+poly(Cmd.Fuel.Rail.Press.Ma
> nual,2)
>
> +poly(Compressor.Inlet.Temperature,2)+poly(Diesel.LHV,2)+poly(NG.LHV,2)
>
> +Engine.Speed*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +X..NG.by.Energy*(Engine.Speed+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Int.Mfld.Temp*(X..NG.by.Energy+Engine.Speed+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Advance.Angle*(X..NG.by.Energy+Int.Mfld.Temp+Engine.Speed+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Engine.Power*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.S
> peed+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Fuel.Rail.Press.Manual*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.
> Angle+Engine.Power+Engine.Speed+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Compressor.Inlet.Temperature*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advanc
> e.Angle+Engine.Power+Cmd.Fuel.Rail.Press.Manual+Engine.Speed+Diesel.LHV
> +NG.LHV)
>
> +Diesel.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Pow
> er+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Engine.Speed
> +NG.LHV)
>
> +NG.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+C
> md.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+Engin
> e.Speed),data=xsys)
>
>
>
> secfitted.modely6.gimep<-lm( Avg.COV.GIMEP
> ~poly(Engine.Speed,2)+poly(X..NG.by.Energy,2)+poly(Int.Mfld.Temp,2)+pol
> y(Cmd.Advance.Angle,2)+poly(Engine.Power,2)+poly(Cmd.Fuel.Rail.Press.Ma
> nual,2)
>
> +poly(Compressor.Inlet.Temperature,2)+poly(Diesel.LHV,2)+poly(NG.LHV,2)
>
> +Engine.Speed*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +X..NG.by.Energy*(Engine.Speed+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Int.Mfld.Temp*(X..NG.by.Energy+Engine.Speed+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Advance.Angle*(X..NG.by.Energy+Int.Mfld.Temp+Engine.Speed+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Engine.Power*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.S
> peed+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Fuel.Rail.Press.Manual*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.
> Angle+Engine.Power+Engine.Speed+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Compressor.Inlet.Temperature*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advanc
> e.Angle+Engine.Power+Cmd.Fuel.Rail.Press.Manual+Engine.Speed+Diesel.LHV
> +NG.LHV)
>
> +Diesel.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Pow
> er+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Engine.Speed
> +NG.LHV)
>
> +NG.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+C
> md.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+Engin
> e.Speed),data=xsys)
>
> secfitted.modely7.ts<-lm( Turbo.Speed
> ~poly(Engine.Speed,2)+poly(X..NG.by.Energy,2)+poly(Int.Mfld.Temp,2)+pol
> y(Cmd.Advance.Angle,2)+poly(Engine.Power,2)+poly(Cmd.Fuel.Rail.Press.Ma
> nual,2)
>
> +poly(Compressor.Inlet.Temperature,2)+poly(Diesel.LHV,2)+poly(NG.LHV,2)
>
> +Engine.Speed*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +X..NG.by.Energy*(Engine.Speed+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Int.Mfld.Temp*(X..NG.by.Energy+Engine.Speed+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Advance.Angle*(X..NG.by.Energy+Int.Mfld.Temp+Engine.Speed+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Engine.Power*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.S
> peed+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Fuel.Rail.Press.Manual*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.
> Angle+Engine.Power+Engine.Speed+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Compressor.Inlet.Temperature*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advanc
> e.Angle+Engine.Power+Cmd.Fuel.Rail.Press.Manual+Engine.Speed+Diesel.LHV
> +NG.LHV)
>
> +Diesel.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Pow
> er+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Engine.Speed
> +NG.LHV)
>
> +NG.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+C
> md.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+Engin
> e.Speed),data=xsys)
>
>
>
> secfitted.modely8.imp<-lm( Intake.Manifold.Pressure
> ~poly(Engine.Speed,2)+poly(X..NG.by.Energy,2)+poly(Int.Mfld.Temp,2)+pol
> y(Cmd.Advance.Angle,2)+poly(Engine.Power,2)+poly(Cmd.Fuel.Rail.Press.Ma
> nual,2)
>
> +poly(Compressor.Inlet.Temperature,2)+poly(Diesel.LHV,2)+poly(NG.LHV,2)
>
> +Engine.Speed*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +X..NG.by.Energy*(Engine.Speed+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Int.Mfld.Temp*(X..NG.by.Energy+Engine.Speed+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Advance.Angle*(X..NG.by.Energy+Int.Mfld.Temp+Engine.Speed+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Engine.Power*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.S
> peed+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Fuel.Rail.Press.Manual*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.
> Angle+Engine.Power+Engine.Speed+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Compressor.Inlet.Temperature*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advanc
> e.Angle+Engine.Power+Cmd.Fuel.Rail.Press.Manual+Engine.Speed+Diesel.LHV
> +NG.LHV)
>
> +Diesel.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Pow
> er+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Engine.Speed
> +NG.LHV)
>
> +NG.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+C
> md.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+Engin
> e.Speed),data=xsys)
>
>
> secfitted.modely9.maf<-
> lm(Emiss..1..EPA.MAF..Dry.~poly(Engine.Speed,2)+poly(X..NG.by.Energy,2)
> +poly(Int.Mfld.Temp,2)+poly(Cmd.Advance.Angle,2)+poly(Engine.Power,2)+p
> oly(Cmd.Fuel.Rail.Press.Manual,2)
>
> +poly(Compressor.Inlet.Temperature,2)+poly(Diesel.LHV,2)+poly(NG.LHV,2)
>
> +Engine.Speed*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +X..NG.by.Energy*(Engine.Speed+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Int.Mfld.Temp*(X..NG.by.Energy+Engine.Speed+Cmd.Advance.Angle+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Advance.Angle*(X..NG.by.Energy+Int.Mfld.Temp+Engine.Speed+Engine.P
> ower+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Engine.Power*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.S
> peed+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Cmd.Fuel.Rail.Press.Manual*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.
> Angle+Engine.Power+Engine.Speed+Compressor.Inlet.Temperature+Diesel.LHV
> +NG.LHV)
>
> +Compressor.Inlet.Temperature*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advanc
> e.Angle+Engine.Power+Cmd.Fuel.Rail.Press.Manual+Engine.Speed+Diesel.LHV
> +NG.LHV)
>
> +Diesel.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Pow
> er+Cmd.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Engine.Speed
> +NG.LHV)
>
> +NG.LHV*(X..NG.by.Energy+Int.Mfld.Temp+Cmd.Advance.Angle+Engine.Power+C
> md.Fuel.Rail.Press.Manual+Compressor.Inlet.Temperature+Diesel.LHV+Engin
> e.Speed),data=xsys)
>
>
> ####stepwise forward regression for first order
>
> step(fitted.modely1.temp.l,direction="forward")
> step(fitted.modely2.avg.pcp,direction="forward")
> step(fitted.modely3.bshc,direction="forward")
> step(fitted.modely4.bsco,direction="forward")
> step(fitted.modely5.gets,direction="forward")
> step(fitted.modely6.gimep,direction="forward")
> step(fitted.modely7.ts,direction="forward")
> step(fitted.modely8.imp,direction="forward")
> step(fitted.modely9.maf,direction="forward")
>
>
> step(fitted.modely1.temp.l,direction="backward")
> step(fitted.modely2.avg.pcp,direction="backward")
> step(fitted.modely3.bshc,direction="backward")
> step(fitted.modely4.bsco,direction="backward")
> step(fitted.modely5.gets,direction="backward")
> step(fitted.modely6.gimep,direction="backward")
> step(fitted.modely7.ts,direction="backward")
> step(fitted.modely8.imp,direction="backward")
> step(fitted.modely9.maf,direction="backward")
>
>
> now after this step I want to find out outliers in each fitted model
> and remove them from xsys data set and update it .
> Ii want a function which will find one by one outlier and remove it .
> The condition is that outlier would be consider as outlier if its r
> student I greater than +3 and -3.
> I want all in loop and repeat loop till no outlier is remained.
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
________________________________
Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu.
V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá.
This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system.
If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email.
In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient.
More information about the R-help
mailing list