Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hi. it\'s regression R code problem. this is my dat ****************************

ID: 3323341 • Letter: H

Question

hi. it's regression R code problem.

this is my dat

*******************************************************************************

rows <- rep(c("B1","B2"), 3)
rows <- as.factor(rows)
cols <- as.factor(rep(c("A1","A2","A3"),2)) # transforamtion into facto

y <- c(9,4,10,5,11,6)

*******************************************************************************

And here, i want to change this two way Anova as regreesion model like Y=XB+e

also i want to get the value X and beta when there is constraint "sum-to-zero constraint"

can you plz plz help me?

plus two pic i have uploaded are the notations about transformation, anova -> regreesion and "sum-to-zero constraint"

(2) Estimation We can write the ANOVA model as a multiple linear regression model y-X + , however, X is not a full-rank matrix, so that XX is singular Therefore, we cannot have the unique solution for in the normal equa- tion; In this case, we have to assign some constraints. Assume that X is n × p (p

Explanation / Answer

The R function aov() can be used to answer this question. The function summary.aov() is used to summarize the analysis of variance model.

You may use the code as shown:

ANOVA_1 <- aov(y ~ rows + cols)
summary(ANOVA_1)

to include interaction, use

ANOVA_2 <- aov(y ~ rows + cols+rows*cols)
summary(ANOVA_2)

to write it in form of y=xb+error, use

anova_reg= lm(y ~ rows + cols)

summary(anova_reg)

on running this you will get,

Call:
lm(formula = y ~ rows + cols)

Residuals:
1 2 3 4 5 6
-0.5 -1.0 -0.5 0.5 1.0 0.5

Coefficients:
Estimate Std. Error t value Pr(>|t|)  
(Intercept) 9.500 1.000 9.500 0.0109 *
rowsB2 -5.000 1.000 -5.000 0.0377 *
colsA2 0.500 1.225 0.408 0.7226  
colsA3 1.000 1.225 0.816 0.5000  
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.225 on 2 degrees of freedom
Multiple R-squared: 0.9277, Adjusted R-squared: 0.8193
F-statistic: 8.556 on 3 and 2 DF, p-value: 0.1064

you will get all the estimated value of the parameters from which you can form the equation.