R - Pass column names as Variable with names contain I() Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to sort a dataframe by multiple column(s)Drop data frame columns by nameHow to interpret output from three-piece linear regression in RWhich linear model summary row corresponds to which term in formula?Pass offset arguments into lm functionGet p value and R squared values for Simple linear model by group in RHow to interpret and quantify coefficients of slope and intercept in segmented regressionHow to conduct linear hypothesis test on regression coefficients with a clustered covariance matrix?Coefficients of all Dummy Factor variables in GLMFast pairwise simple linear regression between variables in a data frame

Why is an operator the quantum mechanical analogue of an observable?

What ability score does a Hexblade's Pact Weapon use for attack and damage when wielded by another character?

What is this word supposed to be?

Would reducing the reference voltage of an ADC have any effect on accuracy?

Multiple fireplaces in an apartment building?

Protagonist's race is hidden - should I reveal it?

How would this chord from "Rocket Man" be analyzed?

Implementing 3DES algorithm in Java: is my code secure?

std::is_constructible on incomplete types

What's parked in Mil Moscow helicopter plant?

How long after the last departure shall the airport stay open for an emergency return?

Why isn't everyone flabbergasted about Bran's "gift"?

What is the least dense liquid under normal conditions?

Does Mathematica have an implementation of the Poisson Binomial Distribution?

How to get even lighting when using flash for group photos near wall?

What is the ongoing value of the Kanban board to the developers as opposed to management

How can I wire a 9-position switch so that each position turns on one more LED than the one before?

Is Diceware more secure than a long passphrase?

Is Bran literally the world's memory?

Co-worker works way more than he should

Justification for leaving new position after a short time

I preordered a game on my Xbox while on the home screen of my friend's account. Which of us owns the game?

Do I need to protect SFP ports and optics from dust/contaminants? If so, how?

Error: Syntax error. Missing ')' for CASE Statement



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



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to sort a dataframe by multiple column(s)Drop data frame columns by nameHow to interpret output from three-piece linear regression in RWhich linear model summary row corresponds to which term in formula?Pass offset arguments into lm functionGet p value and R squared values for Simple linear model by group in RHow to interpret and quantify coefficients of slope and intercept in segmented regressionHow to conduct linear hypothesis test on regression coefficients with a clustered covariance matrix?Coefficients of all Dummy Factor variables in GLMFast pairwise simple linear regression between variables in a data frame



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















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 to input the I(UI_2^2) coefficient to the glht()



Thank you very much










share|improve this question



















  • 2





    Suggest you use edit facilities to add Minimal, Complete, and Verifiable example

    – 42-
    Mar 9 at 6:32

















1















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 to input the I(UI_2^2) coefficient to the glht()



Thank you very much










share|improve this question



















  • 2





    Suggest you use edit facilities to add Minimal, Complete, and Verifiable example

    – 42-
    Mar 9 at 6:32













1












1








1








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 to input the I(UI_2^2) coefficient to the glht()



Thank you very much










share|improve this question
















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 to input the I(UI_2^2) coefficient to the glht()



Thank you very much







r non-linear-regression coefficients hypothesis-test






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 8:41







cloud

















asked Mar 9 at 6:01









cloudcloud

83




83







  • 2





    Suggest you use edit facilities to add Minimal, Complete, and Verifiable example

    – 42-
    Mar 9 at 6:32












  • 2





    Suggest you use edit facilities to add Minimal, Complete, and Verifiable example

    – 42-
    Mar 9 at 6:32







2




2





Suggest you use edit facilities to add Minimal, Complete, and Verifiable example

– 42-
Mar 9 at 6:32





Suggest you use edit facilities to add Minimal, Complete, and Verifiable example

– 42-
Mar 9 at 6:32












1 Answer
1






active

oldest

votes


















0














The issue seems to be that I(UI^2) can be interpreted as an expression in R in the same fashion you did here LnModel_1 <- lm(formula = PROF ~ UI_1+UI_2+I(UI_1^2)+UI_1:UI_2+I(UI_2^2))



Therefore, you should indicate R that you want to evaluate a string inside your string:



slope <- glht(LnModel_1, linfct = c("UI_2+ UI_1:UI_2*2.5+ 2*2.5*`I(UI_2^2)` =0
") )


Check my example (since I cannot reproduce your problem):



library(multcomp)

cars <- copy(mtcars)
setnames(cars, "disp", "UI_2")
model <- lm(mpg~I(UI_2^2),cars)

names(coef(model))

slope <- glht(model, linfct = c("2*2.5*`I(UI_2^2)` =0") )





share|improve this answer























  • Thank you so much. It works.

    – cloud
    Mar 11 at 9:04











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074487%2fr-pass-column-names-as-variable-with-names-contain-i%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














The issue seems to be that I(UI^2) can be interpreted as an expression in R in the same fashion you did here LnModel_1 <- lm(formula = PROF ~ UI_1+UI_2+I(UI_1^2)+UI_1:UI_2+I(UI_2^2))



Therefore, you should indicate R that you want to evaluate a string inside your string:



slope <- glht(LnModel_1, linfct = c("UI_2+ UI_1:UI_2*2.5+ 2*2.5*`I(UI_2^2)` =0
") )


Check my example (since I cannot reproduce your problem):



library(multcomp)

cars <- copy(mtcars)
setnames(cars, "disp", "UI_2")
model <- lm(mpg~I(UI_2^2),cars)

names(coef(model))

slope <- glht(model, linfct = c("2*2.5*`I(UI_2^2)` =0") )





share|improve this answer























  • Thank you so much. It works.

    – cloud
    Mar 11 at 9:04















0














The issue seems to be that I(UI^2) can be interpreted as an expression in R in the same fashion you did here LnModel_1 <- lm(formula = PROF ~ UI_1+UI_2+I(UI_1^2)+UI_1:UI_2+I(UI_2^2))



Therefore, you should indicate R that you want to evaluate a string inside your string:



slope <- glht(LnModel_1, linfct = c("UI_2+ UI_1:UI_2*2.5+ 2*2.5*`I(UI_2^2)` =0
") )


Check my example (since I cannot reproduce your problem):



library(multcomp)

cars <- copy(mtcars)
setnames(cars, "disp", "UI_2")
model <- lm(mpg~I(UI_2^2),cars)

names(coef(model))

slope <- glht(model, linfct = c("2*2.5*`I(UI_2^2)` =0") )





share|improve this answer























  • Thank you so much. It works.

    – cloud
    Mar 11 at 9:04













0












0








0







The issue seems to be that I(UI^2) can be interpreted as an expression in R in the same fashion you did here LnModel_1 <- lm(formula = PROF ~ UI_1+UI_2+I(UI_1^2)+UI_1:UI_2+I(UI_2^2))



Therefore, you should indicate R that you want to evaluate a string inside your string:



slope <- glht(LnModel_1, linfct = c("UI_2+ UI_1:UI_2*2.5+ 2*2.5*`I(UI_2^2)` =0
") )


Check my example (since I cannot reproduce your problem):



library(multcomp)

cars <- copy(mtcars)
setnames(cars, "disp", "UI_2")
model <- lm(mpg~I(UI_2^2),cars)

names(coef(model))

slope <- glht(model, linfct = c("2*2.5*`I(UI_2^2)` =0") )





share|improve this answer













The issue seems to be that I(UI^2) can be interpreted as an expression in R in the same fashion you did here LnModel_1 <- lm(formula = PROF ~ UI_1+UI_2+I(UI_1^2)+UI_1:UI_2+I(UI_2^2))



Therefore, you should indicate R that you want to evaluate a string inside your string:



slope <- glht(LnModel_1, linfct = c("UI_2+ UI_1:UI_2*2.5+ 2*2.5*`I(UI_2^2)` =0
") )


Check my example (since I cannot reproduce your problem):



library(multcomp)

cars <- copy(mtcars)
setnames(cars, "disp", "UI_2")
model <- lm(mpg~I(UI_2^2),cars)

names(coef(model))

slope <- glht(model, linfct = c("2*2.5*`I(UI_2^2)` =0") )






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 9 at 9:52









LocoGrisLocoGris

2,7481828




2,7481828












  • Thank you so much. It works.

    – cloud
    Mar 11 at 9:04

















  • Thank you so much. It works.

    – cloud
    Mar 11 at 9:04
















Thank you so much. It works.

– cloud
Mar 11 at 9:04





Thank you so much. It works.

– cloud
Mar 11 at 9:04



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074487%2fr-pass-column-names-as-variable-with-names-contain-i%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко