On 10/01/2021 2:17 p.m., varin sacha via R-help wrote:> Dear R-experts,
>
> I dont get any error message but I can't get the green curve/line on
the plot.
> What is going on ? How to solve my problem ?
Look at the values of robustfit.new. They are far smaller than any of
the other values, and don't fall in the range of the plot. I think
you've messed up the call to robustgam().
Duncan Murdoch
>
> Here is the R code :
>
> ####################
>
PIB.hab<-c(12000,34000,25000,43000,12500,32400,76320,45890,76345,90565,76580,45670,23450,34560,65430,65435,56755,87655,90755,45675)
>
ISQ.2018<-c(564,587,489,421,478,499,521,510,532,476,421,467,539,521,478,532,449,487,465,500)
>
>
A=c("Australie","Autriche","Belgique","Canada","Chili","R?p.
Tch?que","Danemark","Estonie","Finlande","France","Allemange","Gr?ce","Hongrie","Islande","Irlande","Isra?l","Italie","Japon","Cor?e","Lettonie")
>
> plot(ISQ.2018,PIB.hab)
>
> library(basicPlotteR)
>
> # Add non-overlapping text labels
>
> addTextLabels(ISQ.2018, PIB.hab, A, col.label="black")
>
>
> ## LOESS FIT
> mod=loess(PIB.hab~ISQ.2018,span=1)
> yfit=predict(mod,newdata=ISQ.2018)
> o=order(ISQ.2018)
> lines(ISQ.2018[o],yfit[o],col="blue",lwd=2)
>
> #GAM
> library(mgcv)
> fit3=gam(PIB.hab~s(ISQ.2018,bs='ps'))
> x.new<- seq(range(ISQ.2018)[1], range(ISQ.2018)[2])
> gamfit.new <-
as.vector(predict.gam(fit3,data.frame(ISQ.2018=x.new),type="response"))
> lines(x.new, gamfit.new, col="red", lwd=2)
>
> #Robust GAM
> library(robustgam)
> true.family <- poisson()
> fit=robustgam(PIB.hab,ISQ.2018,
sp=0,family=true.family,smooth.basis='ps',K=3)
> x.new <- seq(range(ISQ.2018)[1], range(ISQ.2018)[2])
> robustfit.new <- pred.robustgam(fit, data.frame(X=x.new))$predict.values
> lines(x.new, robustfit.new, col="green", lwd=2)
> ####################
>
> ______________________________________________
> 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.
>