[R] stepAIC problem
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Aug 22 11:12:29 CEST 2013
On 22/08/2013 09:24, Sachinthaka Abeywardana wrote:
> Hi all,
>
> I get the expected behaviour of getting a useful model if I do the following
This is an 'expectation problem', not a 'stepAIC problem'.
And stepAIC is not part of R and you are not crediting the tools you use.
>
> fit<-lm(
> expressions[,i]~expressions[,pa_all[1]]+expressions[,pa_all[2]]+expressions[,pa_all[3]]+expressions[,pa_all[4]]+expressions[,pa_all[5]])
> step<-stepAIC(fit, direction="both")
>
> Output:
> Step: AIC=-78.75
>
> expressions[, i] ~ expressions[, pa_all[5]]
>
> Df Sum of Sq RSS AIC
> <none> 43.714 -78.750
> + expressions[, pa_all[4]] 1 0.83982 42.874 -78.690
> + expressions[, pa_all[2]] 1 0.80449 42.909 -78.608
> - expressions[, pa_all[5]] 1 1.13431 44.848 -78.188
> + expressions[, pa_all[1]] 1 0.08445 43.630 -76.944
> + expressions[, pa_all[3]] 1 0.07620 43.638 -76.925
>
>
>
>
> but if I do this instead, stepAIC isn't deleting any of the unwanted
> columns. It seems to think it can only delete the entire set or none at all.
There is only one set to consider. You have a matrix as your single rhs
term. (We must guess: your code is incomplete and not reproducible.)
>
> fit<-lm(expressions[,i]~expressions[,pa_all[1:5]])step<-stepAIC(fit,
> direction="both")
>
>
> Output:
>
> Start: AIC=-74.42
> expressions[, i] ~ expressions[, pa_all[1:5]]
>
> Df Sum of Sq RSS AIC
> - expressions[, pa_all[1:5]] 5 2.7111 44.848 -78.188
> <none> 42.137 -74.424
>
> Step: AIC=-78.19
> expressions[, i] ~ 1
>
> Df Sum of Sq RSS AIC
> <none> 44.848 -78.188
> + expressions[, pa_all[1:5]] 5 2.7111 42.137 -74.424
>
>
> Thanks,
>
> Sachin
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
PLEASE do.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list