can you generate R code for this one can generate data analysis for this one model.matrix(~ a:b) ; lm(z ~ a:b) model.mat

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

can you generate R code for this one can generate data analysis for this one model.matrix(~ a:b) ; lm(z ~ a:b) model.mat

Post by answerhappygod »

can you generate R code for this one
can generate data analysis for this one
model.matrix(~ a:b) ; lm(z ~ a:b)
model.matrix(~ a * b) ; lm(z ~ a * b)
model.matrix(~ a:x) ; lm(z ~ a:x)
model.matrix(~ a * x) ; lm(z ~ a * x)
model.matrix(~ b * (x + y)) ; lm(z ~ b * (x + y))
R will reduce the set of design variables for an interaction term
between categorical variables if a main effect is present. but not
detect the singularity caused by the presence of the
intercept.
There’s no singularities in either of the two cases involving a
categorical and a continuous variable, but the first one has one
parameter less (common-intercept model).
The last example has a “coincidental” singularity (x and y are
proportional within each level of b) which R has no chance of
detecting.
You can easily see that the model matrix is singular since the sum
of the last two columns (b2:x and b2:y) is proportional to the
second (b2), and also the difference between the x and y columns is
a linear combination of b2 and b2:x.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply