Dear list members,

I have an additive linear model (see below fro a reproducible example) and I
want to use the function "predict" to have the value of the response
variable for each level of factor f1 and each level of factor f2 in the
additive model (not interaction). When I did predict I only get 2 values.

y=rnorm(40,1,1)

f1=c(rep("a",20),rep("b",20))
f2=c(rep("a",10),rep("b",10),rep("a",10),rep("b",10))

data=data.frame(y,f1,f2)

mod1 = lm(y ~ f1 + f2, data=data)

summary(mod1)

newData = data.frame(f1 = factor(c("a", "b")), f2 = factor(c("b", "a")))

> predict(mod1, newdata = newData, appendData  =  TRUE)
        1         2
1.0460148 0.9468983

Thank you very much in advance.

Best,

Manuel

-- 
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspinola@una.ac.cr
mspinola10@gmail.com
Teléfono: (506) 2277-3598
Fax: (506) 2237-7036
Personal website: Lobito de río <https://sites.google.com/site/lobitoderio/>
Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>

	[[alternative HTML version deleted]]

