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

Create lm/glm class object using predetermined beta coefficients

I have a list of beta coefficients values that I generated through a Bayesian analysis in JAGs but would love to simply plug them into a simple function like lm() so that I can use the summary...

View Article


Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0...

After using this code: output.lm = count_all %>% group_by(year.y) %>% do(tidy(lm(ENS~total.p, data = .)))%>% filter(term == "total.p")output.lmI got the following Error:Error in lm.fit(x, y,...

View Article


Difference between predict() and fitted.values() in lm()

I've found some little differences between predict() and fitted.values() functions in the next...

View Article

I need help running the lm() regression on a TableOne demographics table

I'm trying to run the lm() regression function of the d a demographic table below with information from a dataframe:X HL.both NHL.B.both NHL.W.both HL.F NHL.B.F NHL.W.F HL.M NHL.B.M NHL.W.M HL.none...

View Article

How to use match.call() inside an RC class?

I've written my own little linear regression class, similar to lm, and would like to get it to print the "function call". I looked at the lm code and found match.call(), but I believe this only works...

View Article


long format linear regression performed over each unique two column pairing...

have a df in quasi-long format:df <- data.frame(X= c(1,2,1,2,1,2,1,2), Y= c(1,2,1,2,1,2,1,2), variable = c("A","A","B","B","A","A","B","B"), value = c(.5,.6,1000,1000,.7,.8,2000,2000))the goal is,...

View Article

How do I create a plot comparing two variables with two different lm where...

I am trying to create a scatterplot in rstudio that has data comparing snout-vent length and the bite force of anoles and then have two lines that represent Male data and then Female data. I have been...

View Article

How to force `stat_poly_line()` to use a specific non-zero y-intercept?

Using stat_poly_line() from package 'ggpmisc', one can fit a polynomial to data by default using lm() as method. You can force the fit through zero with either: formula = y ~ x + 0 or formula = y ~ x -...

View Article


Image may be NSFW.
Clik here to view.

Linear regression with geom_smooth() from ggplot2 with categorical variable...

I try to plot a linear regression line to a scatterplot with an ordinal categorical variable on the x-axis. However, no line is plotted with my code (there is also no warning or error). Is it possible...

View Article


Error in (.format.s.statistics.list != "p25") && (.format.s.statistics.list...

I am doing a regression analysis based on results on a survey, where I coded some of them asfirstStepMutatedData <- mydata %>% mutate(republican = ifelse((pid == 2), 1, 0), conservative =...

View Article

How to add lm.augment output to my original dataset

I'm using the following R code in power query, and it's working well to provide me the studentized residuals that I use to flag outliers in a big dataset :As output, I get the 'df' object containing...

View Article

Add abline in ggplot2 which data from lm() result failed

I want to add abline() to the scatter plot , blow code only can return the scatter plot (the abline can't show). Anyone can help on this ? Thanks!library(tidyverse)model <- lm(mpg~...

View Article

object not found in mediation model

I have to plan a simple mediation model - https://cran.r-project.org/package=mediationlibrary(mediation)mediation_model = lm(as.numeric(Age) ~ as.numeric(condition), data =...

View Article


Using function lm() with group_by in R

I'm trying to create some lm() models for every level of the categorical variable, from one dataframe.I used function lm() with group_by, but it doesn't work, creating only one model.Of course, it is...

View Article

R: Finding extrema of formula generated dynamically from lm()

I would like to generate functions from lm() models' coefficients and variables and use nlminb() to find the extrema. Using predict() does not give the resolution I need. The lm() models have several...

View Article


Joint significance in prais_winsten() generated model. How to get an "lm"...

I'm running the following regression on my data set called datay ~ x1 + x2 + x3 + x4 + tI know that the residuals are serially correlated, so I create a model that takes that into account with...

View Article

Error: cannot coerce class ‘"lm"’ to a data.frame

Prior to running the code in question:library(car);library(compute.es);library(effects); library(ggplot2);library(multcomp); library(pastecs); library(effectsize)Data_Assignment7 =...

View Article


Error using pool ( ) with imputed data when using mice in r

I'm quit new to R.I would like to conduct a linear regression with my imputed data.This is my imputation code (works fine):imp <- mice(impu, predictorMatrix=pred, method=meth, m=10, seed =...

View Article

How to return the last two lines of summary output from a linear model in R?

After finding a regression prediction in lm I want to return only last two lines of the summary. What would be the best function to use?my_model_lm(y ~ x1 + x2 + x3, data = [data])summary_result <-...

View Article

Dynamic fixed effect model

I am trying to test the hypothesis of economic convergence in European countries. I have found that a consistent estimator is Bias corrected LSDV (see, Kiviet (1995)). I've seen that there is a...

View Article
Browsing all 124 articles
Browse latest View live