# Questions tagged [lm]

lm is the name of the linear model (i.e. multiple regression) function in the statistics package R. For linear models in general use the linear-model tag instead.

280 questions
Filter by
Sorted by
Tagged with
25 views

### Effect size for ANCOVA in R (lm with factor and covariate)

I have data on survival (time in minutes) for animals (salt-marsh hoppers Orchestia gammarellus) from saline and brackish plots, and my model shows a statistically clear interaction between salinity ...
30 views

### Why do the calculated means in lm() differ from emmeans()?

Let's assume we have the data: ...
41 views

### Residuals in regression

When evaluating residuals for a linear model, do we plot them against the fitted values or the x values. Here I have an example in R. Do we want the first or second ...
9 views

### Does lm() discount the shared variance between co-linear predictors? i [closed]

I am using lm() to do a multivariate regression as I need to control for different variables. I would like to see what my main regressor explains above and beyond the confound variables I need to ...
12 views

### How to analyze repeated-measures between-subject data using R?

I have to analyze data from an study with following design: I measure the subjects' response to a series of stimuli on a 4-level Likert-scale. Each subjects sees 10 different stimuli, but they are the ...
41 views

### Why is my categorical variable split up into separate variables in my regression model in r

I'm creating a multivariate model in R right now. When I plot categorical variables into the lm() function and check the summary() output, my categorical variable gets split up into a beta ...
24 views

### Do I need to create dummy variables to fit a seasonal model?

Per what I understood from the 2nd chapter of "Time series analysis" by Shumway. When doing a seasonal model in R, you may want to use a dummy variable to tell lm() that a given month value's should ...
30 views

### Can I calculate the residuals of the linear regression with the data of the t.test?

I would like, if possible, to calculate the residuals of lm, with the data output by t.test. How could this be done? This is ...
10 views

### How do I use lm to find a point on a line of best fit through a scatter graph for a given y value? [closed]

I have a scatter graph I have plotted and got the summary statistics for using lm. I need to find a x value for a series of y values which were previously calculated in the code. I was unsuccessful ...
62 views

### lm (linear regression) function generated un-removable outliers [closed]

I have performed linear regression (lm) on two modified p-value types: q-value and Benjamini-Hochberg. Results gives two astronomical outliers, however, after removal of those, new outliers are always ...
17 views

### Compare age groups in panel data

I have some panel data across several years for several countries. Some individuals were treated at the age of 18 and from there on every individual that became 18 was treated. eg: In the year 2000 ...
17 views

### SpatioTemporal regression

I have a data-set containing rain value for 6 stations and station coordinates (lat,lon). I used lm function taking lat,lon,day, their interaction and rain as below: ...
39 views

### ANOVA Basics in R

I have a data table data. The column y is numeric and the column x is character. I create ...
57 views

### should I correct for number of models?

I've built about 8 models, each testing slightly different things but within the scope of the same study. ...
51 views

### What is the difference between multiple regression WITH interaction, and WITHOUT interaction? (* vs + vs " vs : in lm)

I am attempting to set up a multiple regression model using "lm", but I am unsure whether to use :, + or * to indicate the interaction between multiple predictor variables. ?lm shows the following ...
9 views

### Rstudio error message lm [closed]

When I try to a linear regression model of my data and put in lm(DrinkDeath_1_1_~A1+A2+A3) I keep getting this: Error in model.frame.default(formula = DrinkDeath_1_1_ ~ A1, drop.unused.levels = TRUE) :...
15 views

### Difference in differences regression with treatment at different times for different countries

I found an article about DID regression online: https://www.princeton.edu/~otorres/DID101R.pdf As far as I understand the countries A, B, C and D are the control group and E, F and G are the treatment ...
9 views

### R: extract subset of correlation statistics from larger correlated group

I have a simple x,y,z dataset that is highly correlated by a linear model of x and y, and ...
33 views

### Why do a paired t-test and lm give different t-values in R? [closed]

I was playing around with some data, trying to get a grip on doing contrasts for within-subjects designs in R. I've noticed that, as far as I can tell, using lm or <...
20 views

### time series model with low pacf

I have data on annual temperatures covering 21 years, measured at one single loaction. I want to build a regressive model to find out whether there was a significant warming during that time span. I ...
37 views

### T-test while controlling for second measure [closed]

I want to compare the means of a measure collected under two conditions $A$ and $B$. I have one observation per condition per subject so testing the difference against 0 using Student's t-test is ...
17 views

### Standardizing dataset before comparing slopes in regression

I have 3 different yield parameters data which was obtained from four different locations. Here is the distribution of dataset at all locations. I want to determine which yield component is strongly ...
22 views

### “CATEGORICAL” predictor that varies both within and across clusters

Page 13 of THIS ARTICLE (top of the page) recommends that if a continuous predictor varies both within and across clusters, a strategy is to break that predictor into two predictors by: (a) taking ...
47 views

### Statistics help! Reporting ANOVA results!

I am new to statistics and I need some help in understanding how to report the data of some tests I am running on R, I hope this is the right place! I have a dataset: ...
35 views

### Limit the upper predicted values in r

I'm trying to predict rainfall. But the log model gives very high prediction for certain values. Please check the plot for actual vs predicted values. Is it possible to limit/restrict the upper ...
29 views

### Regression with paired, repeated measures design

I have a large population of books. Each book is either a hardback or softback (thus hardback and softback books are paired with one another by title), and can fall into two categorical genres - ...
31 views

### Comparing multiple lm results created in ggplot2 [closed]

I have the following example plot: Created via: ...
46 views

### Regression: Why does using quadratic expressions work with linear estimators? [duplicate]

My questions is, that I see people using R´s lm() (linear regression model) with Y ~ X^2 e.g. here: Simple non-linear regression problem But I dont see how and ...
76 views

### HELP: LM shows no relationship, but LMM does

My research question is assessing if a variable (let’s call it ‘x') can predict another variable (let’s call it ‘y’). The two variables x and y are in the same units, but they just come from ...
82 views

### Calculate the intercept from lm

I would like to understand how I can compute by hand the intercept from lm. The following example is a fractional factorial design (3^3) and the variables are factors. ...
36 views

### R - Interpretation of coefficients and written form of fitted model in lm() linear regression when using poly()

I've tried reading several resources on poly(), I'm not able to see an answer to my question. My question pertains how I might present my fitted linear model in a way that the coefficients are ...
31 views

### question about lm function in R

I have a simple question to ask regarding the lm function (and linear models in general). I am trying to predict y based on x, z, and a x*z interaction. If I simply predict y based on x I get the ...
160 views

### Why is the type I error (power?!) for shapiro.test on studentized residuals on lm is 10% and for regular residuals is just 5%?

I understand that the residuals from a regression model are not i.i.d. Hence, checking if they are normal (even when we know it is the case), should be a problem since they are dependent. The ...
16 views

### Post Hoc Tests with a lm model where model assumptions are violated

I have the following data set: dependent variable is carbon levels in manure. Independent varibale is the month that the manure was collected in (12 level factor). I want to test if there is a ...
17 views

### Placing constraints on linear model coefficients

I have this bit of data : ...
32 views

### Calculate coefficients in multiple regression

I have a model where tree height is a function of diameter and species type. (Tree height)^n= a0+ a1*Diameter+ a2*Type I would like to calculate the coefficients ...
11 views

### Predicting values in a data frame using appropriate log-logistic model

I am supposed to predict the concentration values (conc) for control and treat group in the column in the data frame, ref values should stay the same. ...
44 views

### Linear model for paired data [closed]

We have 100 subjects of varying and known age and sex with two strongly related dependent variables (X, Z) measured with two methods (A and B). Method B is known and expected to show more reduced ...
37 views

### Its my model a Mixed model?

I am running some analysis with mixed model with R. I get differents measures from differents persons (person as random effect), during this analysis and looking plots for each people vs measures I ...
50 views

### How to read lm() plots for models with factors

I'm trying to get a handle on how to read the Residuals vs Fitted and Scale-Location plots of lm() objects when the predictors are a mix of continuous and factor ...
276 views

### Repeated measures anova: lm vs lmer

I'm trying to reproduce several interaction test between with both lm and lmer on repeated measures (2x2x2). The reason I want ...
75 views

### Correct R formula syntax for lm (or manyglm) for a hierachial experimental design

I have an experimental data set where there are a 16 fish in 4 tanks (64 fish). There are two treatments - Heated and Control and four tanks. Heated was done in tank 1 and 2 whilst Control in Tank 3 ...
59 views

### When transform variables to int or to ordinal variables to compute a linear regression model in R?

I am working in R with a database that contains variables as seasons, months, days, temperature, humidity and cnt (integer values). I want to compute a linear model using cnt as the dependent variable ...
24 views

### Single model with unique intercept and slope for each observation

I'm trying to use R to generate a linear model with a unique intercept and slope for each observation - effectively, a single linear model for each observation but contained within a single lm object. ...
248 views

### Using a given polynomial formula in a lm() model in R

I am currently trying to fit a polynomial model to measurement data using the lm() function. fit_poly4 <- lm(y ~ poly(x, degree = 4, raw = T), weights = w) ...
25 views

### How to test zero hypothesis with a linear model lm

I would like to test a zero hypothesis on a linear model in R ( H0: F = 0, H1: F/= 0). How do I do it? Is it adequate to just use a linear model and if its not significant, then H0 is true? My Code ...
81 views

### Repeated measures ANOVA in R (split-split-plot design)

I am trying to fit a repeated measures ANOVA from an experiment with a split-split-plot design and several measures over time. The experimental design is as follows: I have 9 blocks in the field. ...
160 views

### Can eta squared be used for comparing effect size of a categorical (>2 categories) and continuous variable?

I have a linear model with both continuous and categorical (>2 categories) variables. I am aware of other statistics (e.g., AIC sum of weights and lmg from R package relaimpo) that can be used to ...