Skip to content

Commit

Permalink
s and pb
Browse files Browse the repository at this point in the history
  • Loading branch information
mstasinopoulos committed Oct 17, 2024
1 parent 5b5e3a9 commit 89a84b0
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions vignettes/s_pb.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ format:
bibliography: gamlss2.bib
nocite: |
@Rigby+Stasinopoulos:2005
@Stasinopoulosetal2021
<!-- @Stasinopoulosetal2021 -->
<!-- @Rigbyetal2019 -->
<!-- @Stasinopoulos2018 -->
Expand Down Expand Up @@ -46,5 +46,45 @@ library("gamlss2")

- the **local polynomial** smoothing, @Clevelandetal93.

There are several ways to use smoothers within the original GAMLSS framework and they are described in Chapter 9 of @Stasinopoulosetal2017. Local polynomials smoothers can be used with `gamlss2` by connection the `R` function `loess()` with `gamlss2` using `specials`. This connection is described in a different vignette `Mikis` reference here. Here we give an explanation of how use the smooth terms `s()` and `pb()` withing `gamlss2`.
There are several ways to use smoothers within the original GAMLSS framework and they are described in Chapter 9 of @Stasinopoulosetal2017. Local polynomials smoothers can be used with `gamlss2` by connection the `R` function `loess()` with `gamlss2` using `specials`. This connection is described in a different vignette (`Mikis` reference here). Here we give an explanation of how use the smooth terms `s()` and `pb()` within `gamlss2`.

## The `s()` function

The function `s()` is using penalized regression smoothers and it is identical to the function `s()` used in the `R` package `mgcv`. Note that all the argument in the `mgcv` function apply here as well.
```{r}
#| warning: false
library(gamlss2)
library(gamlss)
gm11 <- gamlss2(rent~s(area)+s(yearc)+location+bath+kitchen,
data=rent99, family=GA)
```

To see the fited smooth function try

```{r}
plot(gm11)
```


```{r}
gm21 <- gamlss2(rent~s(area,yearc)+location+bath+kitchen,
data=rent99, family=GA)
plot(gm21)
```


## The `pb()` function

```{r}
gm1 <- gamlss2(rent~pb(area)+pb(yearc)+location+bath+kitchen,
data=rent99, family=GA)
plot(gm1)
```


```{r}
gm2 <- gamlss2(rent~pb(area,yearc)+location+bath+kitchen,
data=rent99, family=GA)
```

0 comments on commit 89a84b0

Please sign in to comment.