Extracts the estimated coefficients from vgam() objects.

coefvgam(object, type = c("linear", "nonlinear"), ...)

Arguments

object

A vgam object.

type

Character. The default is the first choice.

...

Optional arguments fed into coefvlm.

Details

For VGAMs, because modified backfitting is performed, each fitted function is decomposed into a linear and nonlinear (smooth) part. The argument type is used to return which one is wanted.

Value

A vector if type = "linear". A list if type = "nonlinear", and each component of this list corresponds to an s term; the component contains an S4 object with slot names such as "Bcoefficients", "knots", "xmin", "xmax".

Author

Thomas W. Yee

See also

Examples

fit <- vgam(agaaus ~ s(altitude, df = 2), binomialff, data = hunua)
coef(fit)  # Same as coef(fit, type = "linear")
#>         (Intercept) s(altitude, df = 2) 
#>       -1.301849e+00        3.919178e-05 
(ii <- coef(fit, type = "nonlinear"))
#> $`s(altitude, df = 2)`
#> An object of class "vsmooth.spline.fit"
#> Slot "Bcoefficients":
#>               [,1]
#>  [1,] -0.453131264
#>  [2,] -0.451322597
#>  [3,] -0.442279265
#>  [4,] -0.427810243
#>  [5,] -0.402498437
#>  [6,] -0.375402178
#>  [7,] -0.335771519
#>  [8,] -0.299930993
#>  [9,] -0.255644000
#> [10,] -0.220742389
#> [11,] -0.169548167
#> [12,] -0.128439200
#> [13,] -0.084801002
#> [14,] -0.062303539
#> [15,] -0.033305655
#> [16,] -0.002757622
#> [17,]  0.029051673
#> [18,]  0.058376346
#> [19,]  0.079808659
#> [20,]  0.108794279
#> [21,]  0.129387573
#> [22,]  0.156436270
#> [23,]  0.173520062
#> [24,]  0.186318882
#> [25,]  0.190391025
#> [26,]  0.191789712
#> [27,]  0.188788943
#> [28,]  0.177870024
#> [29,]  0.163726970
#> [30,]  0.144508534
#> [31,]  0.121863793
#> [32,]  0.093749308
#> [33,]  0.044210464
#> [34,] -0.014026052
#> [35,] -0.102520326
#> [36,] -0.175954116
#> [37,] -0.254379233
#> [38,] -0.322914456
#> [39,] -0.424639054
#> [40,] -0.548255268
#> [41,] -0.844790483
#> [42,] -1.223243055
#> [43,] -1.548915695
#> [44,] -1.657494172
#> 
#> Slot "knots":
#>  [1] 0.000000000 0.000000000 0.000000000 0.000000000 0.001515152 0.007575758
#>  [7] 0.012121212 0.022727273 0.030303030 0.045454545 0.053030303 0.068181818
#> [13] 0.075757576 0.098484848 0.106060606 0.118181818 0.121212121 0.136363636
#> [19] 0.151515152 0.159090909 0.174242424 0.181818182 0.204545455 0.212121212
#> [25] 0.242424242 0.257575758 0.280303030 0.287878788 0.318181818 0.333333333
#> [31] 0.363636364 0.378787879 0.393939394 0.424242424 0.439393939 0.484848485
#> [37] 0.515151515 0.560606061 0.575757576 0.606060606 0.636363636 0.681818182
#> [43] 0.727272727 0.909090909 1.000000000 1.000000000 1.000000000 1.000000000
#> 
#> Slot "xmin":
#> s(altitude, df = 2) 
#>                   0 
#> 
#> Slot "xmax":
#> s(altitude, df = 2) 
#>                 660 
#> 
#> 
is.list(ii)
#> [1] TRUE
names(ii)
#> [1] "s(altitude, df = 2)"
slotNames(ii[[1]])
#> [1] "Bcoefficients" "knots"         "xmin"          "xmax"