Buenas María Jesús:
El código siguiente crea un conjunto de datos de prueba y hace las regresiones
set.seed(189)
d <- data.frame(C1=runif(10), C2=runif(10), C3=runif(10), C4=runif(10))
for(i in 2:4) {
cat(paste0('Regresión de C1 sobre C', i, '\n'))
print(summary(lm(d[,1]~d[,i], data=d)))
}
El resultado es
Regresión de C1 sobre C2
Call:
lm(formula = d[, 1] ~ d[, i], data = d)
Residuals:
Min 1Q Median 3Q Max
-0.26865 -0.11550 0.04684 0.09090 0.28609
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.1347 0.1285 1.048 0.325
d[, i] 0.5614 0.2148 2.613 0.031 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.1742 on 8 degrees of freedom
Multiple R-squared: 0.4605, Adjusted R-squared: 0.3931
F-statistic: 6.829 on 1 and 8 DF, p-value: 0.03097
Regresión de C1 sobre C3
Call:
lm(formula = d[, 1] ~ d[, i], data = d)
Residuals:
Min 1Q Median 3Q Max
-0.45419 -0.09579 -0.00127 0.19858 0.21673
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.3013 0.1764 1.708 0.126
d[, i] 0.2184 0.2572 0.849 0.420
Residual standard error: 0.2271 on 8 degrees of freedom
Multiple R-squared: 0.08268, Adjusted R-squared: -0.03198
F-statistic: 0.7211 on 1 and 8 DF, p-value: 0.4205
Regresión de C1 sobre C4
Call:
lm(formula = d[, 1] ~ d[, i], data = d)
Residuals:
Min 1Q Median 3Q Max
-0.236182 -0.062773 -0.005496 0.083195 0.191111
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.8785 0.1092 8.045 4.2e-05 ***
d[, i] -0.9176 0.2110 -4.349 0.00245 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.1293 on 8 degrees of freedom
Multiple R-squared: 0.7027, Adjusted R-squared: 0.6656
F-statistic: 18.91 on 1 and 8 DF, p-value: 0.002449
Espero que te sirva.
Un saludo.