Description Usage Arguments Author(s) Examples
Computes projection trimmed regression in 2 dimensions.
1 | trimProjReg2d(x, y, alpha = 0.1)
|
x |
Independent variable |
y |
Dependent variable |
alpha |
Percentage of trimmed observations |
Zygmunt Zawadzki from Cracow University of Economics.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #EXAMPLE 1
data(pension)
plot(pension)
abline(lm(Reserves~Income,data = pension), lty = 3, lwd = 2) #lm
abline(trimProjReg2d(pension[,1],pension[,2]), lwd = 2) #trimprojreg2d
legend("bottomright", c("OLS","TrimLS"), lty = 1:2)
#EXAMPLE 2
data(under5.mort)
data(inf.mort)
data(maesles.imm)
data2011=na.omit(cbind(under5.mort[,22],inf.mort[,22],maesles.imm[,22]))
x<-data2011[,3]
y<-data2011[,2]
plot(x,y,cex=1.2, ylab="infant mortality rate per 1000 live birth",
xlab="against masles immunized #'
percentage", main='Projection Depth Trimmed vs. LS regressions')
abline(lm(x~y,data = pension), lwd = 2, col='black') #lm
abline(trimProjReg2d(x,y), lwd = 2,col='red') #trimmed reg
legend("bottomleft",c("LS","TrimReg"),fill=c("black","red"),cex=1.4,bty="n")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.