[R] Formula in a model

Gerrit Eichner Gerrit.Eichner at math.uni-giessen.de
Wed Sep 11 11:48:18 CEST 2013


Hello, Paulito,

first, I think you haven't received an answer yet because you did not 
"provide commented, minimal, self-contained, reproducible code" as the 
posting guide does request it from you.

Second, see inline below.

On Wed, 11 Sep 2013, Paulito Palmes wrote:

> Hi,
>
> I have a data.frame with dimension 336x336 called *training*, and 
> another one called *observation* which is 336x1. I combined them as one 
> table using table=data.frame(training, observation). table now has 
> 336x337 dimension with the last column as the observation to learn using 
> the training data of the rest of the column in the table. For 
> prediction, i combined the testing data and observation and pass it like 
> predict(model,testingWTesingObservation)
>
>
> I've used the formula: rpart(table[,337] ~ ., data=table) or 
> svm(table[,337] ~ ., data=table).

I am not familiar with rpart() nor with svm() but "table[,337] ~ ., data = 
table" has the consequence that table[,337] is also in the right hand side 
of the formula, so that your "observations" are also in the "training" 
data. That doesn't seem to make sense to me, and is different from the 
call to svm() below.

  Hth  --  Gerrit

> I recently discovered that this formulation produces different model 
> from the: svm(training, observation) formulation. Which is correct and 
> why one of them is not correct? I thought that syntactically, both are 
> the same. I hope that R should be able to detect the error in one of the 
> formulation to avoid the possibility of using it.
>
> Regards,
> Paul
> 	[[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.



More information about the R-help mailing list