Skip to content
/ GFLglm Public

Generalized fused Lasso for grouped data in generalized linear models

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

ohishim/GFLglm

Repository files navigation

GFLglm v0.1.0

This package gives generalized fused Lasso estimator for generalized linear models via coordinate descent algorithm. Furthermore, this package includes the R package GFLlogit.

cite this package of the latest version:
Ohishi, M. (2024). GFLglm: Generalized fused Lasso for grouped data in generalized linear models. R package version 0.1.0. https://github.com/ohishim/GFLglm

Installation

You can install the current version of GFLglm like so:

devtools::install_github("ohishim/GFLglm")

Example

This example requires the following packages:

library(GFLglm)
library(magrittr)

This package has the dataset crimetko used in Ohishi (2024) like this

head(crimetko)
#>   year area crime pop group
#> 1 2017    1   714   8     1
#> 2 2017    1    76   5     1
#> 3 2017    1    44   4     1
#> 4 2017    1   275  22     1
#> 5 2017    1    61   4     1
#> 6 2017    1    47 526     1

The crime is the number of crimes of which the original data was collected by the Metropolitan Police Department, available at TOKYO OPEN DATA (https://portal.data.metro.tokyo.lg.jp/). This variable is arranged and used the following production:

The pop is population of which the original data was obtained from the results of the population census, as provided in e-Stat (https://www.e-stat.go.jp/en). This variable is arranged and used.

This package also has the dataset adj of adjacent relationship of groups in crimetko like this

head(adj)
#>   g adj
#> 1 1   2
#> 2 1   3
#> 3 1   4
#> 4 1   5
#> 5 1   6
#> 6 1  54

For example, group 1 is adjacent to groups 2, 3, 4, 5, 6, 54, … For such a data, Poisson regression with generalized fused Lasso can be executed as

y <- crimetko$crime                           # the response variable  
group <- crimetko$group                       # group id
D <- adj %$% split(adj, g)                    # adjacent relationship
q <- crimetko$pop %>% inset(.==0, 1) %>% log  # offset for log-link

res <- GFLglm(y, group, D, "Poisson", offset=q)

The fourth parameter specifies the error distribution which can take “Gaussian”, “Binomial”, “Poisson”, “Negative.Binomial” (or “NB”), “Gamma”, or “Inverse.Gaussian” (or “IG”). For “Gamma”, “NB”, and “IG”, there is a option using log-link by setting link = "log".

Reference

  1. Ohishi, M. (2024). Generalized fused Lasso for grouped data in generalized linear models. Stat. Comput., 34, 124. doi: 10.1007/s11222-024-10433-5

About

Generalized fused Lasso for grouped data in generalized linear models

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Languages