[R] Gam with mrf smoother (mgcv)
Giulia Carella
Giulia.Carella at lsce.ipsl.fr
Mon Feb 26 15:06:28 CET 2018
Hallo,
I want to use gam from the mgcv package with a mrf smoother.
This is my data set (`x`)
y id
1 0.6684496 1
2 0.6684496 2
3 0.6684496 3
4 0.6684496 4
5 0.6684496 5
6 0.6684496 6
7 0.6684496 7
8 0.5879492 8
9 0.5879492 9
10 0.5879492 10
11 0.5879492 11
12 0.5879492 12
13 0.5879492 13
14 0.5879492 14
15 0.6445448 15
16 0.6445448 16
17 0.6445448 17
18 0.6445448 18
19 0.6445448 19
20 0.6445448 20
21 0.6445448 21
22 0.5815767 22
23 0.5815767 23
24 0.5815767 24
25 0.5815767 25
26 0.5815767 26
27 0.5815767 27
28 0.5815767 28
29 0.6636673 29
30 0.6636673 30
31 0.6636673 31
32 0.6636673 32
33 0.6636673 33
34 0.6636673 34
35 0.6636673 35
36 0.4249320 36
37 0.4249320 37
38 0.4249320 38
39 0.4249320 39
40 0.4249320 40
41 0.4249320 41
42 0.4249320 42
and this is my neighbouring structure (nb)
$`1`
[1] 1 2 3 4 5 6 7
$`2`
[1] 1 2 3 4 5 6 7
$`3`
[1] 1 2 3 4 5 6 7
$`4`
[1] 1 2 3 4 5 6 7
$`5`
[1] 1 2 3 4 5 6 7
$`6`
[1] 1 2 3 4 5 6 7
$`7`
[1] 1 2 3 4 5 6 7
$`8`
[1] 8 9 10 11 12 13 14
$`9`
[1] 8 9 10 11 12 13 14
$`10`
[1] 8 9 10 11 12 13 14
$`11`
[1] 8 9 10 11 12 13 14
$`12`
[1] 8 9 10 11 12 13 14
$`13`
[1] 8 9 10 11 12 13 14
$`14`
[1] 8 9 10 11 12 13 14
$`15`
[1] 15 16 17 18 19 20 21
$`16`
[1] 15 16 17 18 19 20 21
$`17`
[1] 15 16 17 18 19 20 21
$`18`
[1] 15 16 17 18 19 20 21
$`19`
[1] 15 16 17 18 19 20 21
$`20`
[1] 15 16 17 18 19 20 21
$`21`
[1] 15 16 17 18 19 20 21
$`22`
[1] 22 23 24 25 26 27 28
$`23`
[1] 22 23 24 25 26 27 28
$`24`
[1] 22 23 24 25 26 27 28
$`25`
[1] 22 23 24 25 26 27 28
$`26`
[1] 22 23 24 25 26 27 28
$`27`
[1] 22 23 24 25 26 27 28
$`28`
[1] 22 23 24 25 26 27 28
$`29`
[1] 29 30 31 32 33 34 35
$`30`
[1] 29 30 31 32 33 34 35
$`31`
[1] 29 30 31 32 33 34 35
$`32`
[1] 29 30 31 32 33 34 35
$`33`
[1] 29 30 31 32 33 34 35
$`34`
[1] 29 30 31 32 33 34 35
$`35`
[1] 29 30 31 32 33 34 35
$`36`
[1] 36 37 38 39 40 41 42
$`37`
[1] 36 37 38 39 40 41 42
$`38`
[1] 36 37 38 39 40 41 42
$`39`
[1] 36 37 38 39 40 41 42
$`40`
[1] 36 37 38 39 40 41 42
$`41`
[1] 36 37 38 39 40 41 42
$`42`
[1] 36 37 38 39 40 41 42
However, when I run
b <- gam(y ~ s(id,bs="mrf",xt=list(nb=nb)),data=x,method="REML")
I get the following error:
Error in initial.sp(w * x, S, off) : S[[1]] matrix is not +ve definite.
Why is the penalty matrix non semi-positive definite? Am I defining
something wrong?
Many thanks in advance
More information about the R-help
mailing list