0

I'm trying to build a simple linear model. There is a source table variable data_star

            x_st      y_st
    1   7.202602 4.0315130
    2   7.405203 2.4836105
    ...
    52 17.535288 7.2934321
    53 17.737890 3.7034159

looks pretty simple, but rstudio says that

model_new_star = lm('y_st~10.26909+x_st', data = data_star)

has invalid model formula in ExtractVars. What am i missing?

what's more fun is that

model_star = lm("y_st~x_st", data = data_star)

works just fine

  • Hi toxicarchont, welcome to StackOverflow! You cannot define a fixed constant in a formula in that way. I think the following provides an answer to your question: https://stackoverflow.com/questions/7333203/linear-regression-with-a-known-fixed-intercept-in-r – Bas Dec 15 '20 at 09:10
  • hello, thank You, apparently all i needed was an I() over number+x_st, the question You linked to helped! – toxicarchont Dec 15 '20 at 09:32

1 Answers1

0

add an I() over 10.26909+x_st, so that fornula looks like

model_new_star = lm(y_st~I(10.26909+x_st))

that is due to the fact that R interprets arithmetic operators in formulas differently