I wish to analyze an unbalanced data set with 3 variables Tleaf, Tair, and orientation (factor with two levels). Considering the effect of the factor "orientation", I wish to determine if "Tair" has a significant effect on Tleaf and to determine the estimate of the parameter of Tair (I want to know the slope "a" of Tleaf=a(Tair)+b). Considering that the data set is unbalanced (1400 observations for the first level of the factor "orientation" and 1000 observations for the second level) and considering an interaction between orientation*Tair, here is what I've done with the functions lsmeans() et lstrends() of the package "lsmeans":
a=read.table("data.txt", header=TRUE) options(contrasts = c("contr.sum","contr.poly")) mod=lm(Tleaf~orientation*Tair, na.action="na.exclude", data=a) org.lsm=lsmeans(modJuin,~TairMax|orientation) summary(org.lsm, infer = c(TRUE,TRUE), level = .95, adjust = "bon")
Here are the results of the summary():
orientation = East: Tair lsmean SE df lower.CL upper.CL t.ratio p.value 22.28218 24.93279 0.1016984 349 24.73277 25.13281 245.164 <.0001 orientation = West: Tair lsmean SE df lower.CL upper.CL t.ratio p.value 22.28218 24.65817 0.1316022 349 24.39934 24.91701 187.369 <.0001 Confidence level used: 0.95
I note that Tair has a significant effect on Tleaf (p<0.0001) and the marginal mean of Tleaf is 24.93°C for the level "East" and 24.66°C for the level "West" of the factor "orientation".
Then, I used the function lstrends() to obtain the estimate of the slope of Tleaf=f(Tair):
pente=lstrends (mod, "orientation", var="TairMax") orientation TairMax.trend SE df lower.CL upper.CL East 0.8568581 0.02292076 349 0.8117779 0.9019383 West 0.9401517 0.03008866 349 0.8809738 0.9993296 Confidence level used: 0.95
I note that the parameter "a" of Tleaf=a*Tair+b is 0.86 (East) and 0.94 (West).
Here are my questions:
1) Is it right to determine the significativity of the variable Tair with lsmeans() and than determine the slope with lstrends?
2) Wouldn't it be possible to obtain the significativity of Tair and the slope estimate of its parameter at the same time? (to save time, code, etc.)
3) Is there any mistake in my understanding of the outputs?