Most voted "lm" questions
The lm function is used to adjust linear models in R.
Learn more…8 questions
Sort by count of
-
9
votes4
answers8280
viewsHow to put the regression line on a graph?
Suppose a linear regression model like the following: set.seed(1) x <- rnorm(100) y <- rnorm(100) + 2*x +10 modelo <- lm(y~x) If I plot y against x, how do I include the regression line in…
-
7
votes3
answers3287
viewsHow to put the regression equation on a graph?
On another question saw how to put the regression line on a graph. But, how to put the regression equation in the graph? For example: Or…
-
5
votes3
answers530
viewsHow to select all data.frame variables at once for a regression?
Suppose the following data.frame: set.seed(1) dados <- data.frame(y=rnorm(100), x1=rnorm(100), x2=rnorm(100), x3=rnorm(100), x4=rnorm(100)) If I want to run a y regression against x1...xn, I can…
-
5
votes1
answer274
viewsAutomatically identify points of influence in a regression
Whenever we make a linear regression, we need to verify that the hypotheses assumed for the model are correct. One of the best ways to do this is through diagnostic graphics. See the example below:…
-
4
votes3
answers180
viewsHow to include a variable high to n in regression
Suppose I have the following data x<-rnorm(100,1,10000) y<-rnorm(100,1,10000)+2*x+x^2 If I use the lm function as follows: model1<-lm(y~x+x^2) The R does not understand that it is to place…
-
3
votes1
answer359
viewsWhat is rank-deficient and how to get around that?
I did a linear regression lm(), where he declared some variables as factor, and I got some Bs as NA as: citySão José NA When I made the prediction, the prediction occurred and I received the…
-
2
votes1
answer40
viewsApply function, extract regression data
I have the following sample: x <- structure(list(POP = structure(c(1L, 12L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 13L, 14L), .Label = c("pop1", "pop10",…
-
0
votes1
answer211
viewsUsing the lm function of R to solve the autocorrelation problem
I’m working with the function. lm(y~x) simple regression, due to tests I checked autocorrelation, so the blibliography indicates a transformation. Something like: Y=B1*(1-p)+B2(X-(p*X[-1])) That…