R ggplot linear regression model containing log function

108 Views Asked by At

R ggplot linear regression model containing log function - is this valid, are we allowed to perform linear regression on model whereby both dependent and independent variable contains log terms.

Example:

mdl1 <- lm(log(abs(y)) ~ log(abs(x1)) + log(abs(x2)) + x3 + x4, data)

predicted_mdl1 <- data %>%
  data_grid(x1, # parameter to check the effect on the model
            x2=1, #log term set to 1 to make it zero
            x3, # categorical variable
            x4) %>%
  add_predictions(mdl1)

predicted_mdl1 %>% 
  ggplot(aes(x = log(x1), y = pred, color = factor(x3))
  )

enter image description here

0

There are 0 best solutions below