[R] Lasso Regression error

Preetam Pal lordpreetam at gmail.com
Sat May 4 15:09:01 CEST 2013


Hi all,
I have a data set containing variables LOSS, GDP, HPI and UE.
(I have attached it in case it is required).

Having renamed the variables as l,g,h and u, I wish to run a Lasso
Regression with l as the dependent variable and all  the other 3 as the
independent variables.

data=read.table("data.txt", header=T)
l=data$LOSS
h=data$HPI
u=data$UE
g=data$GDP

matrix=data.frame(l,g,h,u)
lasso=lars(matrix,l)

But R is throwing an error (shown below) at this:

Error in rep(1, n) : invalid 'times' argument

Can you kindly suggest where I went wrong?

[Just wanted to mention that I am getting the same error when instead of
the matrix of  predictor variables, I am using only a single variable, say,
g : lasso=lars(g,l)]

Appreciate any help.

Thanks,
Preetam
-- 
Preetam Pal
(+91)-9432212774
M-Stat 2nd Year,                                             Room No. N-114
Statistics Division,                                           C.V.Raman
Hall
Indian Statistical Institute,                                 B.H.O.S.
Kolkata.
-------------- next part --------------
  Time	               LOSS	        HPI	         GDP	         UE
12/31/2007	0.015415228	636.1200000	1009642.0000	4.700000000
3/31/2008	0.019658948	639.5000000	1026274.0263	4.700000000
6/30/2008	0.018117609	628.8700000	1025106.4643	5.000000000
9/30/2008	0.016485332	613.7100000	1015979.4019	5.500000000
12/31/2008	0.016916510	607.7400000	987442.00000	6.300000000
3/31/2009	0.018278273	614.5200000	960015.76986	7.500000000
6/30/2009	0.017538295	602.5100000	950120.43148	8.300000000
9/30/2009	0.015227553	588.6100000	954884.72533	8.700000000
12/31/2009	0.015072857	559.7242622	906007.98097	8.764291953
3/31/2010	0.014273862	555.4567968	907017.35752	8.787717985
6/30/2010	0.011576847	509.7149441	812018.56940	8.666473433
9/30/2010	0.009446999	516.8190575	820322.06572	8.432603577
12/31/2010	0.009395241	512.3891743	825190.66157	8.329473700
3/31/2011	0.008447415	503.5479191	844360.87717	8.064076793
6/30/2011	0.006644175	470.4847206	641167.88195	8.295522051
9/30/2011	0.005096770	472.5451205	642125.56548	8.225821087
12/31/2011	0.006574772	476.6826107	643891.13735	7.919498716
3/31/2012	0.006658841	470.3882067	661123.50413	7.794685722
6/30/2012	0.006045554	473.5204989	700309.99021	7.949811968
9/30/2012	0.005367697	486.1438646	705789.73419	8.455191725
				
				
				
				
				
				
				
				
				
				
				
				
				


More information about the R-help mailing list