Multivariate OLS Regression in R

Wieder einmal wurde ich mit der Aufgabe betraut mich mit dem wundervollen Programm R auseinander zu setzen. Diesmal geht es um eine multovariate OLS Regression.
Bei univariaten Regressionen Reicht die Befehlszeile: lm(y~x[,1])
wobei y die abhängige und x[,1] die unabhängige Variable ist.
Ist es dann für eine multivariate Regression ausreichend lm(y~x[,1:5])
als Befehl zu verwenden? Ein Ergebnis wirft das Ding aus, bin mir aber nicht sicher, ob es das ist, was ich will.

Danke schon mal!!!

Phil

Wieder einmal wurde ich mit der Aufgabe betraut …

und wieder einmal hilft ein Blick in die Hilfe :smile:

Bei der Hilfe zu „lm“ steht unter „Arguments“:

formula: an object of class „formula“ (or one that can be coerced to that class): a symbolic description of the model to be fitted. The details of model specification are given under Details.

Und dann steht da unter „Details“:

Models for lm are specified symbolically. A typical model has the form response ~ terms where response is the (numeric) response vector and terms is a series of terms which specifies a linear predictor for response. A terms specification of the form first + second indicates all the terms in first together with all the terms in second with duplicates removed. A specification of the form first:second indicates the set of terms obtained by taking the interactions of all terms in first with all terms in second. The specification first*second indicates the cross of first and second. This is the same as first + second + first:second.

Was Du vielleicht nicht verstanden hast, ist, dass x[,1:5] kein Term ist. Ein Term wäre x[,1]+x[,2]+x[,3]+…

Das steht aber auch nochmal genauer in der Hilfe zu „formula“ (die ja verlinkt ist).

LG
Jochen