powered by
Generate a string with all interactions of a certain degree, to be used in a GAM formula
all_interactions(x, degree = 2)
A string looking like the right hand side of a GAM formula with tensor product interactions.
For example, if x is c("x1","x2","x3"), then all_interactions(x, degree=2) should return
x
c("x1","x2","x3")
all_interactions(x, degree=2)
"te(x1,x2) + te(x1,x3) + te(x1,x3)"
Character vector of variable names
Maximum interaction degree
x <- c("x1","x2","x3") all_interactions(x, 2)
Run the code above in your browser using DataLab