Responsive Ad Area

Share This Post

test

R – Pass column names as Variable with names contain I()

I’m performing the polynomial regression and testing the linear combination of the coefficient. But I’m running to some problems that when I tried to test the linear combination of the coefficient.

LnModel_1 <- lm(formula = PROF ~ UI_1+UI_2+I(UI_1^2)+UI_1:UI_2+I(UI_2^2)) 
summary(LnModel_1)

It output the values below:

Call:
lm(formula = PROF ~ UI_1 + UI_2 + I(UI_1^2) + UI_1:UI_2 + I(UI_2^2))
Residuals:
 Min      1Q  Median      3Q     Max 
-3.4492 -0.5405  0.1096  0.4226  1.7346 
Coefficients:
Estimate Std. Error t value Pr(>|t|)    
(Intercept)  4.66274    0.06444  72.354  < 2e-16 ***
UI_1         0.25665    0.07009   3.662 0.000278 ***
UI_2         0.25569    0.09221   2.773 0.005775 ** 
I(UI_1^2)   -0.15168    0.04490  -3.378 0.000789 ***
I(UI_2^2)   -0.08418    0.05162  -1.631 0.103643    
UI_1:UI_2   -0.02849    0.05453  -0.522 0.601621

Then I use names(coef()) to extract the coefficient names

names(coef(LnModel_1))
output:
[1] "(Intercept)" "UI_1"        "UI_2"        "I(UI_1^2)" 
"I(UI_2^2)""UI_1:UI_2" 

For some reasons, when I use glht(), it give me an error on UI_2^2

slope <- glht(LnModel_1, linfct = c("UI_2+ UI_1:UI_2*2.5+ 2*2.5*I(UI_2^2) =0
") )
Output:
Error: multcomp:::expression2coef::walkCode::eval: within ‘UI_2^2’, the term
‘UI_2’ must not denote an effect. Apart from that, the term must evaluate to
a real valued constant

Don’t know why it would give me this error message. How do input the I(UI_2^2) to the glht()

Thank you very much


R – Pass column names as Variable with names contain I()
R – Pass column names as Variable with names contain I()
test
{$excerpt:n}

Share This Post

Leave a Reply

Your email address will not be Publishedd. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Skip to toolbar