Search code examples
rmodelingexponential

Can R Model Fits Have A Constant?


I am trying to add a constant to my model

 exponential <- lm((log(fallpercent$n_activities)~ 
 ((fallpercent$percentabovebelow1 )+3)) 

This produces the error

Error in terms.formula(formula, data = data) : 
  invalid model formula in ExtractVars. 

I am trying to create a function with the equivalent of y = ex+3.

Ideas on how to do so?


Solution

  • I am trying to create a function with the equivalent of y= e^(x+3) Ideas on how to do so?

    Are you just trying to create this function?

    myFunc <- function(x) {
      exp(x + 3)
    }
    
    myFunc(2)
    [1] 148.4132