# [R] se's and CI's for fitted lines in multivariate regression analysis

Sigrid s.stenerud at gmail.com
Sat Oct 20 20:56:18 CEST 2012

```Hi again,
Thank you so much for the script. Unfortunately, I feel like I might not
have explained things clearly enough from the start. What I’m looking for is
the st. errors or CI intervals for the estimate the parameter for slope and
intercept for each level of each factor.

From the summary table I can find the intercept and slope for all
treatments by adding them up. Here the printout from the summary table:
(I’ll just do for level A and B to illustrate)
Estimate 	Std. Error t value Pr(>|t|)
(Intercept)       18.00299   17.43720   1.032 0.307146
rowpos            -2.88723    1.26369  -2.285 0.026886 *
colpos            -0.08566    3.19131  -0.027 0.978699
treatmentB         1.22690   22.73203   0.054 0.957186
:
colpos:treatmentB  0.39402    4.50194   0.088 0.930628

>From this I can find the lines of A and B by adding up the parameters
A, intercept: 18.00299+(-2.88723)= *15.14267 	*		                A, slope:
*-0.08566*
B, intercept: 18.00299+(-2.88723)+1.22690)= *16.36957*		B, slope:
-0.08566+0.39402=-*0.46258*

It would be nice if I could get the intercept and slope done for me, like
this.....

lm(formula = decrease[treatment == "B"] ~ colpos[treatment ==  "B"])

Coefficients:
(Intercept)  colpos[treatment == "B"]
5.0000                    0.5833
.... but while I do that with my more complicated model, I get an error
message.

>lm(decrease[treatment=="B"]~rowpos[treatment=="B"]+colpos[treatment=="B"]+treatment[treatment=="B"]+treatment:colpos[treatment=="B"])
Error in model.frame.default(formula = decrease[treatment == "B"] ~
rowpos[treatment ==  :
variable lengths differ (found for 'treatment')

So  back to the actual problem; how do I get the standard error of intercept
and slope or CI of those lines (A&B) calculated above? As the coefficients
given in the model are the difference between each factor from ‘A’ it does
not make sense to add them up in the same way as the parameters
themselves....

--
View this message in context: http://r.789695.n4.nabble.com/se-s-and-CI-s-for-fitted-lines-in-multivariate-regression-analysis-tp4645703p4646878.html
Sent from the R help mailing list archive at Nabble.com.

```