by punit agrawal
Last Updated November 17, 2017 13:19 PM

So I having been using R to perform statistical analysis.

The 'lm' function is generally used to create a linear model, and this model can have degree 1 variables by using model= lm (y~ ., data= train)

Similarly degree 2 interaction can be done using model= lm(y~.*., data= train)

To apply regularization, the most preferred package seems to be glmnet, but glmnet can apply regularization only to the original dataset, and not to more complex polynomial models. Is there a way in R I can perform regularization to polynomial interaction terms of the original variables?

```
model.glmnet= glmnet(x= train[,1:4], y= train[,5], alpha=0)
```

P.S.- I do not wish to create those variables in the original dataset as that would be a very tedious task

- ServerfaultXchanger
- SuperuserXchanger
- UbuntuXchanger
- WebappsXchanger
- WebmastersXchanger
- ProgrammersXchanger
- DbaXchanger
- DrupalXchanger
- WordpressXchanger
- MagentoXchanger
- JoomlaXchanger
- AndroidXchanger
- AppleXchanger
- GameXchanger
- GamingXchanger
- BlenderXchanger
- UxXchanger
- CookingXchanger
- PhotoXchanger
- StatsXchanger
- MathXchanger
- DiyXchanger
- GisXchanger
- TexXchanger
- MetaXchanger
- ElectronicsXchanger
- StackoverflowXchanger
- BitcoinXchanger
- EthereumXcanger