[R] NaN response with gam (mgcv library)
Bert Gunter
bgunter@4567 @end|ng |rom gm@||@com
Sun Apr 30 23:13:57 CEST 2023
There is no "residuals" component of a gam fit, as you could have
immediately determined by:
> names(model_summ)
[1] "p.coeff" "se" "p.t"
[4] "p.pv" "residual.df" "m"
[7] "chi.sq" "s.pv" "scale"
[10] "r.sq" "family" "formula"
[13] "n" "dev.expl" "edf"
[16] "dispersion" "pTerms.pv" "pTerms.chi.sq"
[19] "pTerms.df" "cov.unscaled" "cov.scaled"
[22] "p.table" "pTerms.table" "s.table"
[25] "method"
Bert
On Sun, Apr 30, 2023 at 2:03 PM varin sacha via R-help <r-help using r-project.org>
wrote:
> Dear R-experts,
>
> Here below my R code. I get a NaN response for gam with mgcv library. How
> to solve that problem?
> Many thanks.
>
> #########################################################
> library(mgcv)
>
> y=c(23,24,34,40,42,43,54,34,52,54,23,32,35,45,46,54,34,36,37,48)
>
> x1=c(0.1,0.3,0.5,0.7,0.8,0.9,0.1,0.7,0.67,0.98,0.56,0.54,0.34,0.12,0.47,0.52,0.87,0.56,0.71,0.6)
> x2=c(9,7,5,3,2,1,1,2,8,9,6,3,1,5,6,7,3,1,3,5)
> x3=c(11,10,13,15,10,9,14,16,18,19,20,9,13,12,14,17,21,19,23,12)
>
> model=lm(y~x1+x2+x3)
> model1=gam(y ~ s(x1, bs = 'cr', k = 3) + s(x2, bs = 'cr', k = 3)+ s(x3, bs
> = 'cr', k = 3))
>
>
> #Calculate MSE
> model_summ=summary(model)
> mean(model_summ$residuals^2)
>
>
> #Calculate MSE
> model_summ=summary(model1)
> mean(model_summ$residuals^2)
> #########################################################
>
> ______________________________________________
> R-help using 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.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list