lm Questions
5
I'm using lm on a time series, which works quite well actually, and it's super super fast.
Let's say my model is:
> formula <- y ~ x
I train this on a training set:
> train <- data...
4
Solved
I have a simple polynomial regression which I do as follows
attach(mtcars)
fit <- lm(mpg ~ hp + I(hp^2))
Now, I plot as follows
> plot(mpg~hp)
> points(hp, fitted(fit), col='red', pch=...
2
Solved
rich.main3 is a linear model in R. I understand the rest of the elements of the list but I don't get what qraux is. The documentation states that it is
a vector of length ncol(x) which contains...
Halo asked 3/8, 2016 at 10:34
4
I want to run lm() on a large dataset with 50M+ observations with 2 predictors. The analysis is run on a remote server with only 10GB for storing the data. I have tested ´lm()´ on 10K observations ...
4
I am fitting a linear model in R with three variables like so
cube_mod <- lm(y ~ x + x_2 + x_3)
I then use the anova function to display the results of analysis of variance with and get the fol...
4
Solved
I want to test if the slope in a simple linear regression is equal to a given constant other than zero.
> x <- c(1,2,3,4)
> y <- c(2,5,8,13)
> fit <- lm(y ~ x)
> summary(fit)...
1
If I'm running a fixed effects model in r using lm and the factor command, how can I suppress the factor variable coefficients in a stargazer model?
i.e. my model is:
m1<-lm(GDP~pop_growth + f...
4
Solved
I am trying to tweak contrast coding on a linear model where I want to know if each level of a factor is significantly different from the grand mean.
Let’s say the factor has levels "A", ...
Epigraph asked 30/6, 2022 at 18:6
11
Say I have data.frame a
I use
m.fit <- lm(col2 ~ col3 * col4, na.action = na.exclude)
col2 has some NA values, col3 and col4 have values less than 1.
I keep getting
Error in lm.fit(x, y,...
2
Solved
I am confused with the way predict.glm function in R works.
According to the help,
The "terms" option returns a matrix giving the fitted values of each term in the model formula on the linear p...
Amontillado asked 22/6, 2016 at 9:28
3
Solved
R package ggpmisc can be used to show equation of lm model and poly model on ggplot2 (See here for reference). I wonder how I could show nls model equation results on ggplot2 using ggpmisc. Below i...
1
Suppose we want to do a simple 'descriptive model of income.' Suppose we have three groups, North, Central, and South (think US regions).
Comparing otherwise similar groups, suppose average income ...
Midmost asked 11/5, 2021 at 22:57
5
Solved
I know there is a small difference between $sigma and the concept of root mean squared error. So, i am wondering what is the easiest way to obtain RMSE out of lm function in R?
res<-lm(randomDa...
Experiment asked 30/3, 2017 at 16:27
2
Solved
Instead of something like lm(bp~height+age, data=mydata) I would like to specify the columns by number, not name.
I tried lm(mydata[[1]]~mydata[[2]]+mydata[[3]]) but the problem with this is that,...
1
Solved
I am trying to create a correlation matrix between my X and Y variables and display this information in a nice figure. I am currently using ggpairs() from the GGally package, but if there's a bette...
Nutrilite asked 11/2, 2022 at 15:17
2
Solved
I am using lm() on a training set of data that includes a polynomial. When I subset in advance with [ ] I get different coefficients compared to using the subset argument in the lm() function call....
4
Solved
I use R only a little bit and never use data frames, which makes understanding the correct use of predict difficult. I have my data in plain matrices, not data frames, call them a and b, which are ...
1
Solved
I have seen similar posts like this one which say that getting the error message saying: Coefficients: (1 not defined because of singularities) is because of nearly perfect correlation among predic...
Saprolite asked 29/8, 2021 at 18:36
4
Solved
I am looking for just the value of the B1(newx) linear model coefficient, not the name. I just want the 0.5 value. I do not want the name "newx".
newx <- c(0.5,1.5,2.5)
newy <- c(2...
4
Solved
I have a dataset below in which I want to do linear regression for each country and state and then cbind the predicted values in the dataset:
Final data frame after adding three more columns:
I h...
3
Solved
I want to do linear regression with the lm function. My dependent variable is a factor called AccountStatus:
1:0 days in arrears, 2:30-60 days in arrears, 3:60-90 days in arrears and 4:90+ days in ...
Walk asked 5/3, 2014 at 9:0
1
Solved
Cross posted on CrossValidated.
A while ago, I asked this question, which was about correcting the standard errors when using IV/2SLS and the first stage has a tobit distribution, on which I got an...
6
Solved
I was trying to automate a piece of my code so that programming become less tedious.
Basically I was trying to do a stepwise selection of variables using fastbw() in the rms package. I would like ...
3
Solved
My apologies for the dumb question...but I can't seem to find a simple solution
I want to extract the standardized coefficients from a fitted linear model (in R)
there must be a simple way or func...
Glacier asked 19/6, 2014 at 11:17
5
Solved
I found peculiarity while using predict and lm function in R. I got different results for data frame and vector for same data.
DataFrame code:
data(mtcars)
fitCar<-lm(mtcars$mpg~mtcars$wt)
pr...
Babineaux asked 13/12, 2014 at 23:51
1 Next >
© 2022 - 2025 — McMap. All rights reserved.