2
votes

I'm trying to do a multiregression linear model with 10 predictors variables, but when I copy all the variables the model doesn't work.

regresion<-lm(DO~NO3+NO2+SO4+NH4+Mg+Ca+PO4+pH+CI+CE, data=s1)

the output is:

Call:
lm(formula = DO ~ NO3 + NO2 + SO4 + NH4 + Mg + Ca + PO4 + pH + 
CI + CE, data = s1)

Residuals:

ALL 7 residuals are 0: no residual degrees of freedom!

Coefficients: (4 not defined because of singularities)

               Estimate Std. Error t value Pr(>|t|)
(Intercept)    0.20979         NA      NA       NA
NO3            0.27132         NA      NA       NA
NO2         -128.83424         NA      NA       NA
SO4            0.04334         NA      NA       NA
NH4            0.12088         NA      NA       NA
Mg             3.59376         NA      NA       NA
Ca             5.37956         NA      NA       NA
PO4                 NA         NA      NA       NA
pH                  NA         NA      NA       NA
CI                  NA         NA      NA       NA
CE                  NA         NA      NA       NA

Residual standard error:

NaN on 0 degrees of freedom

Multiple R-squared:

1,     Adjusted R-squared:    NaN 

F-statistic:

 NaN on 6 and 0 DF,  p-value: NA

The model tolerance is until 5 variables, and more than this it's an error?

2

2 Answers

1
votes

You are not getting an error. In R errors are called "Errors" while situations that might or might not be a serious problem are called "warnings". You are being warned that it only takes the data from 6 of your variables to construct a "perfect" model, one that has 100% accuracy for predicting your outcome. How this might come about is a matter of speculation at the moment. To clear up that question you should post the output of str(s1) and summary(s1) and probably the top 20 lines of your dataset as it would be viewed in a text editor.

0
votes

ALL 7 residuals are 0: no residual degrees of freedom!

This implies you only have 7 observations in the data frame s1, but you are providing 10 predictors. You need to at least have more observations than predictors, otherwise all the variance will be explained perfectly, and your "model" won't be statistical (hence the NA's for all p-vals).