[R] Leaps & regsubsets

From: Smit, Robin <robin.smit_at_tno.nl>
Date: Wed 02 Mar 2005 - 18:56:01 EST


Hello  

I am trying to use all subsets regression on a test dataset consisting of 11 trails and 46 potential predictor variables. I would like to use Mallow's Cp as a selection criterion. The leaps function would provide the required output but does not work with this many variables (see below).
The alternative function regsubsets should be used, but I am not able to define the function in such a way that is gives satisfactory results.  

library(leaps)

data <- read.table('C:/test_plot_sum2.txt', header = TRUE)

attach(data)

nox <- data[,1]

cnt <- data[,2]

vars <- data[,3:48]  

leaps.setup(x = vars, y = nox, wt = cnt, nvmax = 1)

leaps(x = vars, y = nox, wt = cnt, method = "Cp", nbest = 2, names = names(vars))  

Error in leaps(x = vars, y = nox, wt = cnt, method = "Cp", nbest = 2, :

        leaps does not allow more than 31 variables; use regsubsets()  

regsubsets(x = vars, y = nox, weights = cnt, method = "seqrep", nbest = 1, names = names(vars), nvmax = 3)  

1 subsets of each size up to 4

Selection Algorithm: 'sequential replacement'

Warning message:

37 linear dependencies found in: leaps.setup(x, y, wt = weights, nbest = nbest, nvmax = nvmax,  

Is there someone who could shine a few rays of light on this? Many thanks for your assistance.  

Kind regards,
Robin Smit

This e-mail and its contents are subject to the DISCLAIMER at http://www.tno.nl/disclaimer/email.html

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Mar 02 19:00:33 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:39 EST