T <- c(-1, +1, -1, +1) # centered and scaled temperature
S <- c(-1, -1, +1, +1) # centered and scaled substrate concentration
y <- c(69, 60, 64, 53) # conversion is the response, y
mod <- lm(y ~ T + S + T*S)
summary(mod)
Call:
lm(formula = y ~ T + S + T * S)
Residuals:
ALL 4 residuals are 0: no residual degrees of freedom!
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 61.5 NA NA NA
T -5.0 NA NA NA
S -3.0 NA NA NA
T:S -0.5 NA NA NA
Residual standard error: NaN on 0 degrees of freedom
Multiple R-squared: 1, Adjusted R-squared: NaN
F-statistic: NaN on 3 and 0 DF, p-value: NA
% Set up the X matrix:
n = 4;
temperature = [-1, +1, -1, +1];
substrate = [-1, -1, +1, +1];
X = [ ones(n, 1), temperature', substrate', (temperature .* substrate)'];
% or you can type it in directly (but this is error prone)
X = [+1 -1 -1 +1; ...
+1 +1 -1 -1; ...
+1 -1 +1 -1; ...
+1 +1 +1 +1];
% Conversion is your y-variable
y = [69, 60, 64, 53]';
% Regression coefficients = b = [Intercept, b_T, b_S, b_{TS}]
b = inv(X'*X)*X'*y