- HOW TO CREAT R OUTPUT FOR SIMPLE LINEAR REGRESSION EQUATION HOW TO
- HOW TO CREAT R OUTPUT FOR SIMPLE LINEAR REGRESSION EQUATION FULL
Lm(formula = -mpg ~ cyl + hp + drat, data = mtcars) My naive approach to this problem would also be to customize my own function using paste0(): regEq fit fit The basic formula for a regression line is Y bX + A, where Y is the predicted score, b is the slope of the line, and A is the Y-intercept. This is especially apparent when you see the answer posed here versus the accepted answer on the other page. Why is it different? That questions addresses a one off case of, "how do you extract a linear regression equation from an lm object?" This question is, "is there a an existing base method or (if not) a method for systematically getting the linear regression equation from an lm object.
HOW TO CREAT R OUTPUT FOR SIMPLE LINEAR REGRESSION EQUATION HOW TO
Note: this is quite similar but also not quite the same question as posed here:Įxtract Formula From lm with Coefficients (R) How to use this app Follow these steps: Open the app via this link Enter your data in the x and y fields. I don't think it will be exceptionally difficult to create a function that does the same paste function except on a variable length for the number of coefficients, but it's just something where I would rather go with an existing solution given the end product is such a useless construct. I have crossed my pain threshold for this and today started to think about to create my own function for this, but I'm just checking to see if anyone knows of an existing function that does this automatically. As you can see, my hand and mind are hurting from repeatedly doing this. It would not be a huge problem to copy and paste the paste function above, but he wants the actual variable labels in there instead of y,x1, etc. Suppose I have: lm1 = lm(y~x1+x2.xn, data=df)įor this course in regression I'm taking, the professor repeatedly wants the resulting regression equation in the form: e(y) = b1 +b2x1 bnx(n-1).Ĭurrently, I am doing something like this: (paste("y=", coef(lm1), '+', coef(lm1), '*x2', )
HOW TO CREAT R OUTPUT FOR SIMPLE LINEAR REGRESSION EQUATION FULL
Does anyone know of an existing function to extract the full linear equation from a lm object?