I have a dataset $S$ with $D$ features and three fitted linear regression models:
Model1. Ridge regression that is fitted on all $D$ features from $S$.
Model2. Ridge regression that is fitted on some $d < D$ features from $S$.
Model3. Lasso regression that is fitted on all $D$ features from $S$, and only $m < D$ features got non-zero weights (coefficients) after fitting.
I want to use AIC to select the best model. We know that AIC formula for linear regression models is the following:
$$\mathrm{AIC} = 2k + n \log{(\mathrm{RSS}/n)}.$$
where $k$ is the number or estimated parameters (degrees of freedom) and $n$ is the sample size. So we can easily calculate AIC value for all three models.
And I have two questions:
1. Can I compare AIC's values of these models and choose the best one with the lowest AIC?
I thought that the answer is yes but I became confused after reading documentation for AIC function in R package. It claims that models should be fitted on the same data. Whereas my Model2 is fitted on the (technically) different dataset (on the subset of $S$).
2. What is $k$ value for Model3?
It is clear that $k = D + 2$ for Model1 ($D$ estimates for slope parameters + intercept estimate + $\hat \sigma^2_\varepsilon$ estimate) and, similarly, $k=d+2$ for Model2.
But Model3 have only $m$ non-zero slope parameters after fitting. Does it mean that $k=m + 2$ for Model3?