[R] Help with GAM (mgcv)

Simon Wood s.wood at bath.ac.uk
Mon Dec 6 13:52:47 CET 2010


Probably the problem is with trying to smooth maritalStatus, which is a factor 
variable. Smooths are generally functions of metric variables (i.e. variables 
that take numerical values, where the ordering is meaningful). You can have 
random effect smooths and markov random field smooths in more recent mgcv 
versions (which can take factor arguments), but I doubt that these would be 
all that useful here... I would simply include maritalStatus as a factor 
variable.

On Monday 06 December 2010 11:37, Stressed1985 wrote:
> Thank you for your reply!
>
> It says:
> This is mgcv  1.5-5 . For overview type `help("mgcv-package")'.
>
> Its version: R 2.9.2
>
> And summary(data2) gives:
>
>        id              age             bmi           siblings        gender
>  Min.   :   1.0   Min.   :32.19   Min.   :16.41   Min.   :0.000  
> Female:494 1st Qu.: 273.5   1st Qu.:48.11   1st Qu.:23.44   1st Qu.:1.000  
> Male  :521 Median : 567.0   Median :57.86   Median :25.81   Median :1.000
>  Mean   : 559.5   Mean   :58.72   Mean   :26.42   Mean   :1.401
>  3rd Qu.: 839.5   3rd Qu.:69.06   3rd Qu.:28.90   3rd Qu.:2.000
>  Max.   :1117.0   Max.   :90.02   Max.   :59.25   Max.   :2.000
>    cigarette                        alcohol    coffee     drugs
>  never  :533   None                     :380   No :209   None:930
>  Current:200   At least a glass per week:164   yes:806   yes : 85
>  Former :282   At least a glass per day :471
>
>
>
>   maritalStatus      edu                job        famhxGast       famhxPep
>  Single  :128   Min.   :1.000   Employed  :510   Min.   :1.00   Min.   :1.0
>  Married :793   1st Qu.:1.000   retired   :362   1st Qu.:1.00   1st Qu.:1.0
>  Widowed : 61   Median :2.000   housewife :132   Median :1.00   Median :1.0
>  Divorced: 33   Mean   :1.901   unemployed: 11   Mean   :1.13   Mean   :1.2
>                 3rd Qu.:3.000                    3rd Qu.:1.00   3rd Qu.:1.0
>                 Max.   :4.000                    Max.   :2.00   Max.   :2.0
>     hp_stat    txerad       Symptoms
>  Absent :431   no :923   Min.   :0.000
>  Present:584   yes: 92   1st Qu.:0.000
>                          Median :0.000
>                          Mean   :0.466
>                          3rd Qu.:1.000
>                          Max.   :1.000

-- 
> Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> +44 1225 386603  www.maths.bath.ac.uk/~sw283



More information about the R-help mailing list