# For syntax of least absolute deviation from package 'L1pack' [closed]

I am trying to use the least absolute deviation regression from my dataset which has one column of dependent variable and multiple columns of independent variables. I tried using the following syntax but get errors where the 'co' contains the dataset and the 12th column is my dependent variable:

 co_reg1=lad(co[,12]~co[,2]+co[,3]+co[,5]+co[,7]+co[,8]+co
[,9]+co[,11]+co[,2]*co[,11])


but I get error saying:

 argument "y" is missing, with no default


So I also tried this method:

 co_reg1=lad(cbind(co[,2],co[,3],co[,5],co[,7],co[,8],co[,9],co[,11],co[,2]
*co[,11]),co[,12])


But I still get error saying I need the arguments for x and y to be in matrix form.

May I get help on this?

• It works for me lad(mtcars[,1] ~ mtcars[,2] + mtcars[,3]*mtcars[,4])... The question is off-topic and you didn't provide a reproducible example what makes it impossible to answer. lad takes as argument standard R formula and then parses it using the same methods as functions like lm, so it should work if you use it with valid input data and use it correctly. – Tim May 6 '17 at 19:09
• Now I get it. When I delete a library something like "ldr" package, it works. I tried to call this ldr package to use summary.lad function. However since it seems like I cannot call both functions, probably summary.lad is not supposed to give the summary result for least absolute deviation regression result. Because in some other package lad function means different one if I am correct. So I think there was some collusion. – Eric May 6 '17 at 19:28
• May I know the name of the function? Cuz theoretically people say it is not available. – Eric May 6 '17 at 23:07
• You are right. What kind of summary would you need? – Tim May 7 '17 at 6:35
• t-test for coefficients and for overall f-test and R square values – Eric May 7 '17 at 10:59

Someone's going to complain that this question belongs to other stackoverflow forum. But the quick take on your question is, you need to follow the standard R idiom. That is, for function like lad, it wants a formula like y ~ x1 + ... and a data object. To use your syntax, you want l1fit which accepts a x and y. Just read the documentation carefully.
• @Eric Try use l1fit and see if you get the same error. And read the doc. – horaceT May 6 '17 at 19:08