Quantcast
Channel: Active questions tagged lm - Stack Overflow
Browsing all 122 articles
Browse latest View live

Image may be NSFW.
Clik here to view.

Modify the name of factor variables in lm function(summary function) in r

Sample code:require(datasets); data(InsectSprays)model1 <- lm(count ~ spray, data = InsectSprays) summary(model1)When I run above code, the result is However, the levels of spray is not 1,2,3,4,5,...

View Article


Image may be NSFW.
Clik here to view.

Can I add a randoma effect to stat_poly_eq() in ggplot?

I am interested in adding a random effect to a ggplot using stat_poly_eq().library (ggplot2)library(ggpmisc)data (mtcars)mtcars$gear <- factor (mtcars$gear)mtcars$cyl <- factor...

View Article


Comparing 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 Article

Regression by remove point and check the quality of regression

I want to do a linear regression by removing values ​​to evaluate the performance of the regressions in terms of correlation coefficient in comparison to a threshold valuedatas <- data.frame(x=...

View Article

Subset rows within one predictor in GLM without disturb other

I fit parasitoid abundance to two factors, flower availability and distance of the crop to flower.Firstly, I fit separate glm equation:glm(abundance ~ flower, data = data, family =...

View Article


How to model the event that the LM converges correctly?

I'm utilizing the LM algorithm to solve a trakcing problem. I found that sometimes the LM algorithm will converge to the wrong position at the beginning, and then continue to converge to the wrong...

View Article

geom_smooth (method = "lm", se = False) - I run this and it changes my Y values

I'm having issues when I run geom_smooth. When I run my script without it my y limits are correct, however when I add geom_smooth my y values are incorrect. When I try to set a limit an error pops up...

View Article

How to minimize size of object of class "lm" without compromising it being...

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...

View Article


Can I purge data from model objects in R?

I am estimating a large number of models (lm-type, but possibly others) in r. I do this ion a secure server, from which data export is restricted. I am allowed to export the results from models...

View Article


Clustered Standard Errors

I am running a linear regression where I would like to account for clustering. I wrote some simple sample code below that outlines my question:m1 <- lm(y ~ x + clus, data=dt)coeftest(m1,...

View Article

Image may be NSFW.
Clik here to view.

R6 seems not working properly with stats::lm()

I'm fairly new to both R6 and Object Oriented Programming, that I really couldn't figure out why I can't supply either weights or subset to stats::lm() called by a method. Codes below, where you can...

View Article

How can I compare the results of two lmRob() models?

I am looking for a way to compare the results from two lmRob() functions statistically.Here is an explanation what I am trying to do: My professor wants me to compare the results of two ancovas (one...

View Article

Comparison of coefficient test across subsamples

I am trying to conduct a comparison of coefficient tests across two subsamples. To achieve this, I do the following:full_model <- lm(y ~ v1*subsample_dummy + fixed_effects, data=df)reduced_model...

View Article


R - how to pass a formula to a with(data, lm(y ~ x)) construction

This question is highly related to R - how to pass formula to a with(df, glm(y ~ x)) construction inside a function but asks a broader question.Why do these expressions work?text_obj <- "mpg ~...

View Article

How to calculate variance explained by a variable of interest, in a lm model...

I am working in R on linear regressions with covariates, looking like : lm(x ~ y + a + b + c)With the summary() function, I can get the p value corresponding to each of the variables of the model....

View Article


Problem with effects function : how to get adjusted value from a model?

I encounter using "effect" from effects package. My goal is to extract the values of the fitted model for some values of my predictor. The problem is for a mixed model with quadratic predictors but it...

View Article

Is it possible to read out the coefficients of linear model instead of...

I have the following situation:I have some data and train some linear model on it (potentially with some interaction terms). I save the coefficients of this model, so other programs than R can also use...

View Article


Predict.lm incorrect predictions when using predict with a data frame...

My lm model returns incorrect predictions when using a data frame created from a matrix. I need to used model.matrix to encode some data.My CodeI tried to compare to calculating them manually by hand...

View Article

Adding the predictor variable “H” to a code written for only one predictor...

I want to add the predictor variable “H” to the code below which already contains the response variable “vol” and another predictor variable “dbh”.#Code:Dry.vol.hat <- function (dbh.cm, + ht.dbh.lm...

View Article

loop regression when column names have special characters

Dummy data shown below. I tried amending my loop regression code to account for spaces in the column names, but it still gives an error. Additionally, I'm not sure how to adjust .x to account for...

View Article
Browsing all 122 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>