How to add "slope" function (excel) in R
I'm trying to move data wrangling from excel to R.I have a dataframe (df) with 62 columns and 21 rows. Each of the rows represents a different organisation, and each of the column headings (apart from...
View Articlelm(): What is qraux returned by QR decomposition in LINPACK / LAPACK
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...
View Articleextract coefficients from more than one linear regression model with multiple...
I am trying to generate a data frame of intercepts and coefficients for multiple different linear regression models generated from subsets of a data set. I cannot share my data unfortunately but I can...
View ArticleLinear model slope gives NA when reducing original data
I have a df with a response variable that changes with time. When plotting the data, there is a plateau of which I want to get rid of, since I need the steepest slope of the...
View ArticleHow to force lm() and glm() functions not to refactor weights for linear...
I just want to run lm() and glm() for linear regression without refactoring weights, i.e., to utilize the weights just as they are specified. How can I do that?It is known, but not documented, that the...
View ArticleHow to extract Correlation of Coefficients table from models like glm?
After running a statistical model in R (e.g., glm, lm, lme4::lmer, etc.), I run the summary() command with corr=TRUE to get the Correlation of Coefficients table. It features a matrix of correlations...
View ArticleHow to extract the quadratic fit from stat_smooth when using a transformed axis
I am trying to extract the line for my quadratic fit so that I can work out the x coordinate at y = 0.1 but the lm() and the stat_smooth are giving me different fits because of the log transformation...
View ArticleWhy do I get the same results with different cross-validation specifications...
I am using the caret package for fitting different models with the same data. I am using cross-validation for all of them; however, when I use different number of folds with the lm method, I get the...
View ArticlePlot polynomial regression curve in R
I have a simple polynomial regression which I do as followsattach(mtcars)fit <- lm(mpg ~ hp + I(hp^2))Now, I plot as follows> plot(mpg~hp)> points(hp, fitted(fit), col='red', pch=20)This gives...
View ArticlePlot function issue - adding a line
My goal is to plot a line (red) using the plot function. This is what I have tried so far.data("Nile")plot(Nile)fm0 <- lm(Nile ~ 1) ; summary(fm0)y1 <- c(rep(1097.75, 20), rep(848.9722, 80)) #...
View ArticleOmit output of a factor variable in stargazer?
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 +...
View ArticleR issue: lm() is printing NAs for rows once ncol > nrow [migrated]
I'm running an lm() on lagged variables as part of a network analysis, and have the following dimensions:dim(final)[1] 197 277dim(final_lag)[1] 197 831The final dataset contains the non-lagged...
View ArticleFactor as variable in linear model in r
My dataset is on predictors of diabetes and I am to create a linear model. I initially was going to try out some of the variables but my professor told me it would make the most sense to use whether or...
View ArticleHow should I visualise my interpretation?
I'm doing an analysis on how wind turbine parameters affect wind speed. Dataset from: https://datadryad.org/stash/dataset/doi:10.5061/dryad.vx0k6djxgmod4= lm(wind_speed~turbine_distance* rotor_size...
View ArticleCalculating a critical point of a variable from lm object
The below quadratic model example (including data) is from Steve's Data Tips and Tricks.# Sample Data and Quadratic Modelstudy_hours <- c(6, 9, 12, 14, 30, 35, 40, 47, 51, 55, 60)exam_scores <-...
View ArticleComparing all factor levels to the grand mean: can I tweak contrasts in...
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", "B" and "C"....
View ArticleHow to print a certain part of the summary of a model? [closed]
I wish to print out the part of the model that shows the AIC, MSE, RMSE, BIC, and other statistics of my multilinear regression model:When I do summary(forward_model) it doesn't show these statistics....
View ArticleIn R is it possible to use MAE (Mean Absolute Error) instead of RMSE as the...
I am trying to do several regressions on financial data, and one problem with financial data is that it tends to have lots of extreme outliers that are possibly not all that informational. In R linear...
View ArticleHow can I save results of multiple R models to a csv?
I was able to create a tibble with results of 12 linear models as lists with the code below. These are linear models between average monthly flow (MMF) and watershed area (DRAINAGE_AREA_GROSS) and the...
View ArticleDoes R always return NA as a coefficient as a result of linear regression...
My question is about the unnecessary predictors, namely the variables that do not provide any new linear information or the variables that are linear combinations of the other predictors. As you can...
View Article