Function that constructs default or commonly use penalty matrices according to a (factorial) study design. The constructed penalty matrix can be used directly in optPenalty.fused.auto or serve as basis for modification.

default.penalty(
  G,
  df,
  type = c("Complete", "CartesianEqual", "CartesianUnequal", "TensorProd")
)

Arguments

G

A numeric giving the number of classes. Can also be a list of length G such as the usual argument Slist from other rags2ridges functions. Can be omitted if df is given.

df

A data.frame with G rows and factors in the columns. Note, the columns has to be of type factor. Can be omitted when G is given and type == "Complete". The factors can be ordered.

type

A character giving the type of fused penalty graph to construct. Should be 'Complete' (default), 'CartesianEqual', or 'CartesianUnequal' or 'TensorProd' or an unique abbreviation hereof. See details.

Value

Returns a G by G character matrix which specify the class of penalty graphs to be used. The output is suitable as input for the penalty matrix used in optPenalty.fused.auto.

Details

The type gives a number of common choices for the penalty matrix:

  • 'Complete' is the complete penalty graph with equal penalties.

  • 'CartesianEqual' corresponds to a penalizing along each "direction" of factors with a common penalty. The choice is named Cartesian as it is the Cartesian graph product of the complete penalty graphs for the individual factors.

  • 'CartesianUnequal' corresponds to a penalizing each direction of factors with individual penalties.

  • 'TensorProd' correspond to penalizing the "diagonals" only. It is equivalent to the graph tensor products of the complete graphs for each individual factor.

References

Bilgrau, A.E., Peeters, C.F.W., Eriksen, P.S., Boegsted, M., and van Wieringen, W.N. (2020). Targeted Fused Ridge Estimation of Inverse Covariance Matrices from Multiple High-Dimensional Data Classes. Journal of Machine Learning Research, 21(26): 1-52.

Author

Anders E. Bilgrau, Carel F.W. Peeters <carel.peeters@wur.nl>, Wessel N. van Wieringen

Examples

  # Handling one-way designs
  default.penalty(2)
#>   1        2       
#> 1 "ridge"  "fusion"
#> 2 "fusion" "ridge" 
  default.penalty(4)
#>   1        2        3        4       
#> 1 "ridge"  "fusion" "fusion" "fusion"
#> 2 "fusion" "ridge"  "fusion" "fusion"
#> 3 "fusion" "fusion" "ridge"  "fusion"
#> 4 "fusion" "fusion" "fusion" "ridge" 
  Slist <- vector("list", 6)
  default.penalty(Slist)   # The function uses only the length of the list
#>   1        2        3        4        5        6       
#> 1 "ridge"  "fusion" "fusion" "fusion" "fusion" "fusion"
#> 2 "fusion" "ridge"  "fusion" "fusion" "fusion" "fusion"
#> 3 "fusion" "fusion" "ridge"  "fusion" "fusion" "fusion"
#> 4 "fusion" "fusion" "fusion" "ridge"  "fusion" "fusion"
#> 5 "fusion" "fusion" "fusion" "fusion" "ridge"  "fusion"
#> 6 "fusion" "fusion" "fusion" "fusion" "fusion" "ridge" 
  df0 <- expand.grid(Factor = c("lvl1", "lvl2"))
  default.penalty(df0)
#>      lvl1     lvl2    
#> lvl1 "ridge"  "fusion"
#> lvl2 "fusion" "ridge" 

  # A more elaborate example
  df1 <- expand.grid(DS = c("DS1", "DS2", "DS3"), ER = c("ER+", "ER-"))

  # Usage (various interface demonstrations)
  default.penalty(6, df1, type = "Complete")
#>         DS1:ER+  DS2:ER+  DS3:ER+  DS1:ER-  DS2:ER-  DS3:ER- 
#> DS1:ER+ "ridge"  "fusion" "fusion" "fusion" "fusion" "fusion"
#> DS2:ER+ "fusion" "ridge"  "fusion" "fusion" "fusion" "fusion"
#> DS3:ER+ "fusion" "fusion" "ridge"  "fusion" "fusion" "fusion"
#> DS1:ER- "fusion" "fusion" "fusion" "ridge"  "fusion" "fusion"
#> DS2:ER- "fusion" "fusion" "fusion" "fusion" "ridge"  "fusion"
#> DS3:ER- "fusion" "fusion" "fusion" "fusion" "fusion" "ridge" 
  default.penalty(6, type = "CartesianEqual")  # GIVES WARNING
#> Warning: No data.frame 'df' given and 'type' does not equal 'Complete'. Setting 'type' to 'Complete'
#>   1        2        3        4        5        6       
#> 1 "ridge"  "fusion" "fusion" "fusion" "fusion" "fusion"
#> 2 "fusion" "ridge"  "fusion" "fusion" "fusion" "fusion"
#> 3 "fusion" "fusion" "ridge"  "fusion" "fusion" "fusion"
#> 4 "fusion" "fusion" "fusion" "ridge"  "fusion" "fusion"
#> 5 "fusion" "fusion" "fusion" "fusion" "ridge"  "fusion"
#> 6 "fusion" "fusion" "fusion" "fusion" "fusion" "ridge" 
  default.penalty(6, df1, type = "CartesianEqual")
#>         DS1:ER+  DS1:ER-  DS2:ER+  DS2:ER-  DS3:ER+  DS3:ER- 
#> DS1:ER+ "ridge"  "fusion" "fusion" ""       "fusion" ""      
#> DS1:ER- "fusion" "ridge"  ""       "fusion" ""       "fusion"
#> DS2:ER+ "fusion" ""       "ridge"  "fusion" "fusion" ""      
#> DS2:ER- ""       "fusion" "fusion" "ridge"  ""       "fusion"
#> DS3:ER+ "fusion" ""       "fusion" ""       "ridge"  "fusion"
#> DS3:ER- ""       "fusion" ""       "fusion" "fusion" "ridge" 
  default.penalty(Slist, df1, type = "CartesianEqual")
#>         DS1:ER+  DS1:ER-  DS2:ER+  DS2:ER-  DS3:ER+  DS3:ER- 
#> DS1:ER+ "ridge"  "fusion" "fusion" ""       "fusion" ""      
#> DS1:ER- "fusion" "ridge"  ""       "fusion" ""       "fusion"
#> DS2:ER+ "fusion" ""       "ridge"  "fusion" "fusion" ""      
#> DS2:ER- ""       "fusion" "fusion" "ridge"  ""       "fusion"
#> DS3:ER+ "fusion" ""       "fusion" ""       "ridge"  "fusion"
#> DS3:ER- ""       "fusion" ""       "fusion" "fusion" "ridge" 
  default.penalty(6, df1, type = "CartesianUnequal")
#>         DS1:ER+ DS1:ER- DS2:ER+ DS2:ER- DS3:ER+ DS3:ER-
#> DS1:ER+ "ridge" "ER"    "DS"    ""      "DS"    ""     
#> DS1:ER- "ER"    "ridge" ""      "DS"    ""      "DS"   
#> DS2:ER+ "DS"    ""      "ridge" "ER"    "DS"    ""     
#> DS2:ER- ""      "DS"    "ER"    "ridge" ""      "DS"   
#> DS3:ER+ "DS"    ""      "DS"    ""      "ridge" "ER"   
#> DS3:ER- ""      "DS"    ""      "DS"    "ER"    "ridge"
  default.penalty(df1)
#>         DS1:ER+  DS2:ER+  DS3:ER+  DS1:ER-  DS2:ER-  DS3:ER- 
#> DS1:ER+ "ridge"  "fusion" "fusion" "fusion" "fusion" "fusion"
#> DS2:ER+ "fusion" "ridge"  "fusion" "fusion" "fusion" "fusion"
#> DS3:ER+ "fusion" "fusion" "ridge"  "fusion" "fusion" "fusion"
#> DS1:ER- "fusion" "fusion" "fusion" "ridge"  "fusion" "fusion"
#> DS2:ER- "fusion" "fusion" "fusion" "fusion" "ridge"  "fusion"
#> DS3:ER- "fusion" "fusion" "fusion" "fusion" "fusion" "ridge" 

  # A 2 by 2 by 2 design
  df2 <- expand.grid(A = c("A1", "A2"), B = c("B1", "B2"), C = c("C1", "C3"))
  default.penalty(df2)
#>          A1:B1:C1 A2:B1:C1 A1:B2:C1 A2:B2:C1 A1:B1:C3 A2:B1:C3 A1:B2:C3
#> A1:B1:C1 "ridge"  "fusion" "fusion" "fusion" "fusion" "fusion" "fusion"
#> A2:B1:C1 "fusion" "ridge"  "fusion" "fusion" "fusion" "fusion" "fusion"
#> A1:B2:C1 "fusion" "fusion" "ridge"  "fusion" "fusion" "fusion" "fusion"
#> A2:B2:C1 "fusion" "fusion" "fusion" "ridge"  "fusion" "fusion" "fusion"
#> A1:B1:C3 "fusion" "fusion" "fusion" "fusion" "ridge"  "fusion" "fusion"
#> A2:B1:C3 "fusion" "fusion" "fusion" "fusion" "fusion" "ridge"  "fusion"
#> A1:B2:C3 "fusion" "fusion" "fusion" "fusion" "fusion" "fusion" "ridge" 
#> A2:B2:C3 "fusion" "fusion" "fusion" "fusion" "fusion" "fusion" "fusion"
#>          A2:B2:C3
#> A1:B1:C1 "fusion"
#> A2:B1:C1 "fusion"
#> A1:B2:C1 "fusion"
#> A2:B2:C1 "fusion"
#> A1:B1:C3 "fusion"
#> A2:B1:C3 "fusion"
#> A1:B2:C3 "fusion"
#> A2:B2:C3 "ridge" 
  default.penalty(df2, type = "CartesianEqual")
#>          A1:B1:C1 A1:B1:C3 A1:B2:C1 A1:B2:C3 A2:B1:C1 A2:B1:C3 A2:B2:C1
#> A1:B1:C1 "ridge"  "fusion" "fusion" ""       "fusion" ""       ""      
#> A1:B1:C3 "fusion" "ridge"  ""       "fusion" ""       "fusion" ""      
#> A1:B2:C1 "fusion" ""       "ridge"  "fusion" ""       ""       "fusion"
#> A1:B2:C3 ""       "fusion" "fusion" "ridge"  ""       ""       ""      
#> A2:B1:C1 "fusion" ""       ""       ""       "ridge"  "fusion" "fusion"
#> A2:B1:C3 ""       "fusion" ""       ""       "fusion" "ridge"  ""      
#> A2:B2:C1 ""       ""       "fusion" ""       "fusion" ""       "ridge" 
#> A2:B2:C3 ""       ""       ""       "fusion" ""       "fusion" "fusion"
#>          A2:B2:C3
#> A1:B1:C1 ""      
#> A1:B1:C3 ""      
#> A1:B2:C1 ""      
#> A1:B2:C3 "fusion"
#> A2:B1:C1 ""      
#> A2:B1:C3 "fusion"
#> A2:B2:C1 "fusion"
#> A2:B2:C3 "ridge" 
  default.penalty(df2, type = "CartesianUnequal")
#>          A1:B1:C1 A1:B1:C3 A1:B2:C1 A1:B2:C3 A2:B1:C1 A2:B1:C3 A2:B2:C1
#> A1:B1:C1 "ridge"  "C"      "B"      ""       "A"      ""       ""      
#> A1:B1:C3 "C"      "ridge"  ""       "B"      ""       "A"      ""      
#> A1:B2:C1 "B"      ""       "ridge"  "C"      ""       ""       "A"     
#> A1:B2:C3 ""       "B"      "C"      "ridge"  ""       ""       ""      
#> A2:B1:C1 "A"      ""       ""       ""       "ridge"  "C"      "B"     
#> A2:B1:C3 ""       "A"      ""       ""       "C"      "ridge"  ""      
#> A2:B2:C1 ""       ""       "A"      ""       "B"      ""       "ridge" 
#> A2:B2:C3 ""       ""       ""       "A"      ""       "B"      "C"     
#>          A2:B2:C3
#> A1:B1:C1 ""      
#> A1:B1:C3 ""      
#> A1:B2:C1 ""      
#> A1:B2:C3 "A"     
#> A2:B1:C1 ""      
#> A2:B1:C3 "B"     
#> A2:B2:C1 "C"     
#> A2:B2:C3 "ridge"