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.

Filter by
Sorted by
Tagged with
0 votes
0 answers
33 views

Linear mixed-effects models or one-hot encoding for grouped data

I wish to perform linear regression over a data set whose entries can be divided into two or more groups. The groups could be, for example, the date at which observations where taken, or the patient ...
altroware's user avatar
  • 156
0 votes
0 answers
31 views

Difference in SD of beta weights from lm models [closed]

I have a rather theoretical question. I have calculated several lm models for each of two conditions. One of my conditions comes out with a much larger SD of betas than the other. Are there any ...
Nori's user avatar
  • 1
0 votes
0 answers
18 views

Quadratic relationship binary variable and a factor [duplicate]

I have a set of data collected during over a year. We have created a variable called “bimonthly” (1=January-February; 2=March-April; 3=May-June; 4=July-August; 5=September-October and 6=November-...
JuanJMV's user avatar
1 vote
1 answer
37 views

Shouldn't estimates from grouped data using weights be the same as the estimates from micro data

I was under the impression that weighted regression on grouped data, where the weights are equal to the number of group members, should result in the same estimates as running the regression on the ...
Richard Martin's user avatar
9 votes
2 answers
599 views

How does R lm() function calculate standard error of slopes with more than one predictor? [duplicate]

I am confused as to why the standard error of slopes calculated by the R function 'lm()' differs from the following formula when there is more than one predictor: $$ SE(\hat{\beta}_j) = \sqrt{\frac{\...
GraphiteHB's user avatar
0 votes
0 answers
14 views

What does lm(psp(x,df=0) do in R? [closed]

I have data with incidence rates for each quarter between 2015 and 2022. I am supposed to model the association of the incidence rates with the general time trend(quarter 1-40 as numeric value) and ...
user avatar
0 votes
0 answers
11 views

Can I run a PGLS model with explanatory variables in different units?

I am looking at the effect of altitude on a trait and I want to include the effect of the interaction between latitude and altitude, using a PGLS. Can I include altitude (measured in metres) as one ...
PowellHall's user avatar
0 votes
1 answer
30 views

Which Post-hoc analysis to examine group differences after linear regression model?

I have done a linear regression analysis in R (lm) to predict social unrest. I would now like to do a post hoc analysis to see if my prediction was more accurate for some countries / regions than ...
Ni Na's user avatar
  • 3
3 votes
3 answers
147 views

Heteroscedasticity problem violating assumptions for lm and glm

I’ve been trying to fit some data for a manuscript to a model for the past two days and I keep running into problems with violation of assumptions for the lm and <...
Blanca's user avatar
  • 45
2 votes
1 answer
40 views

how to interpret interacting plot of predictors or how to find which predictors are interacting

I am trying to see which predictors in my dataset are interacting with each other to see if their inclusion can improve model prediction. I followed these steps to do my analysis: First I used ...
Katherin Wright's user avatar
2 votes
0 answers
44 views

Mixed model with censored data in R?

My objective is to see if there is a significant difference in BHB concentration between age categories in farm animals. Farm should be a random effect in the model. The issue is that BHB ...
Falco's user avatar
  • 139
0 votes
0 answers
11 views

Factorial ANOVA with missing cell

I would like to run a two-way ANOVA with interaction between the two factors. I did an experiment with two treatments: Treatment 1 has four levels (A,B,C,D) and treatment 2 has three levels (I, P,F). ...
Ricarda's user avatar
  • 43
1 vote
2 answers
75 views

How interpret Pr(>|t|) results?

How interpret Pr(>|t|) results? Can I consider the "speed" significant for regression despite the "intercept" having no statistical difference? Or the linear regression model is ...
user avatar
0 votes
0 answers
25 views

How can I add an anticipation horizon to my OLS regression?

I am currently writing my thesis and have to submit in 1 week, but am struggling to solve this issue on my own. I would therefore genuinely appreciate your input! The research question I'm trying to ...
Lena's user avatar
  • 1
0 votes
0 answers
88 views

Preferred test for a 2x2 cross-over trial: lmer() or lm()?

I'm conducting a randomized 2x2 cross-over trial of 8 participants measuring the effect of a specific diet (intervention) vs normal diet (control) on the number of sleep hours. The study design ...
Wandering_geek's user avatar
0 votes
0 answers
76 views

Interpretation of a difference-in-difference model

I am running a basic difference-in difference (DiD) model. I would like to explain the effect of increasing the price of fares for students only. I use DiD with adults as a control group. I have ...
vojta9's user avatar
  • 11
1 vote
1 answer
42 views

compare grouped slopes (change over time)

I have a set of measurements over time at specific locations with treatments applied to different locations. I'm interesting in testing whether locations have different responses to the treatments ...
Tim's user avatar
  • 13
1 vote
0 answers
27 views

Limitations with effect sizes and confidence intervals (fixed effects) with lmer and effectsize in R

Background I've been running a couple of lmer() models with different data and noticed something I cannot really grasp. The models range from simple to more complicated (e.g. DV ~ ...
littlekook3's user avatar
0 votes
0 answers
10 views

For a linear regression model, how do I describe the specific impact of treatments?

I want to determine whether the type of concrete I used for an artificial reef had an effect on the critters colonizing the reef. For this, there are: 4 types of concrete (OPC, OPC with algae, CaCO3 ...
Sam Sage's user avatar
0 votes
0 answers
31 views

Compare R2 and Pearson correlation in different models

I have a data set with two variables (var1 and var2) and two binary variables Sex (1,2) and Time (1,2). Therefore, I have four groups. I have calculated pearson correlations and R2 for the four groups....
JuanJMV's user avatar
0 votes
0 answers
62 views

step function for lmer models

The step function in R allows me to select a model based on AIC. lm1 <- lm(mpg ~ ., data = mtcars) slm1 <- step(lm1) Is ...
locus's user avatar
  • 1,181
0 votes
0 answers
21 views

Conceptually understanding random effects in a mixed effects linear model

My goal is to understand how random effects are handled within a mixed-effects linear model. Given this model: ...
user3012926's user avatar
0 votes
1 answer
70 views

Failing to find optimal linear fit in R with lm

I have three linear regression models in R: 1. lm(Y~X1) 2. lm(Y~X2) 3. lm(Y~X2+X3) Of note, in this data mathematically ...
CodeGuy's user avatar
  • 473
1 vote
0 answers
12 views

Modifying ordered factor estimates in linear model

My question starts on previous answered questions: https://stackoverflow.com/questions/25735636/interpretation-of-ordered-and-non-ordered-factors-vs-numerical-predictors-in-m/25736023#25736023 Results ...
iago's user avatar
  • 208
1 vote
0 answers
328 views

linear regression in R: contr.treatment vs contr.sum

Following are two linear regression models with the same predictors and response variable, but with different contrast coding methods. In the first model, the contrast coding method is "contr....
Ed9012's user avatar
  • 41
1 vote
1 answer
38 views

Interpretation of coefficients in a linear regression model with two binary predictors and their interaction

This is the output from a linear regression model that is trying to predict math scores based on the student's gender and whether or not they took a test preparation course. It is just a toy example ...
Ed9012's user avatar
  • 41
0 votes
0 answers
20 views

Controlling for within-subject variance in planned contrasts (lm model)

Somebody asked me about doing planned contrasts with repeated measures (within-subject design). I normally use contrasts with the lm function in R and have no ...
rempsyc's user avatar
  • 251
0 votes
1 answer
85 views

T-test p-value from lm() function does not equal t.test() function in R

I thought the the following code in R should run equivalent t-tests. But the p-value obtained from each method differs. The p-value using lm() is 3.415937e-05 but using t.test() it is 0.0001098368. ...
luciano's user avatar
  • 13.7k
1 vote
0 answers
21 views

How can I get the Basic Estimable Functions for a design matrix in R?

When using the GLM procedure in SAS for an overparametrized ANOVA model, it shows you the General Form of the Estimable Functions for the given model, i.e. the basis of the functions of the model ...
Jef Winant's user avatar
0 votes
1 answer
62 views

Fitting a segmented regression with two zero boundary constraints

I am having trouble with this segmented regression as it requires two constraints and so far I have only treated single constraints. Here is an example of some data I am trying to fit: ...
leonardo's user avatar
0 votes
0 answers
40 views

Starting point for backward selection in polynomial linear models in R

I am reading Generalized Additive Models by Simon N. Wood. I do not have a very strong formal background in maths and statistics, so this question might be too trivial. However, I am well versed in R. ...
sp29's user avatar
  • 101
1 vote
1 answer
61 views

How to interpret multiple linear regression results that don't match graph

I have a scenario where the multiple linear mixed model is outputting a significant main effect of my task variable (which is a factor with 2 levels). However, the visual graph does not suggest a main ...
john connor's user avatar
0 votes
0 answers
32 views

If my model does not meet assumptions should I run as separate categorical variables?

I have 3 main questions: Does my removal of the random effect based on an error message and lack of visible change make sense for this model? Is my interpretation of the results of the linear model ...
pabstack's user avatar
0 votes
0 answers
28 views

Determining the effect of factor variables in a regression model

I've created a regression model in R that is predicting a patient's one-year adherence to a drug while adjusting for the patient's age, sex, region of domicile, whether or not the patient has diabetes,...
amatof's user avatar
  • 11
4 votes
1 answer
221 views

Why does auto.arima have much different intercept and xreg terms as lm?

I have the following library(data.table) library(forecast) testdata<-fread("https://raw.githubusercontent.com/deanm0000/SOexamples/main/testdata.csv") ...
Dean MacGregor's user avatar
0 votes
1 answer
352 views

Fixed effect model: different estimation approaches with R - how to demean variables - unbalanced panel

I want to use R to estimate a fixed effects model using different estimation approaches. Note that I am using an unbalanced panel. The easiest way to do this is using the function ...
shazz's user avatar
  • 1
7 votes
3 answers
1k views

How do you determine if there is a significant relationship between two variables with several factors affecting it, using R?

I want to check if there is a significant relationship between x and y, and then check if this relationship is affected by different stimuli (2 levels), colonies (2 levels), and lightings situation (2 ...
Pegi's user avatar
  • 71
1 vote
1 answer
39 views

determining the effect of the change in an independent variable using regression

I'm creating a regression model that predicts a customer's spending based on their income, while adjusting for age, gender , and region. The model looks as follows: ...
amatof's user avatar
  • 11
1 vote
0 answers
339 views

the Wald, Likelihood Ratio (LR) the Lagrange Multiplier (LM) test statistics Are monotonic function of F statistics

Consider a classic linear regression model. I want to show that the Wald, Likelihood Ratio (LR) the Lagrange Multiplier (LM) test statistics for the null hypothesis $H_0: R\beta =r$ for a constant ...
1190's user avatar
  • 980
0 votes
0 answers
50 views

Precipitation to Mean Temperature Relationship

Based on the data below, I am trying to see if there is any relationship between Precipitation and Mean Temperature. Now the <...
Ed_Gravy's user avatar
  • 111
2 votes
1 answer
69 views

Infer individual power contribution from team efforts

I like to infer the contribution of each rower in a crew boat from a number of races: 8 rowers are split repeatedly into two boats of 4 rowers each. The race over a distance leads to an estimate of ...
Christian Lindig's user avatar
0 votes
1 answer
66 views

What do the p-values for each variable in the output lm() in R mean?

I have a rudimentary understanding of statistics so please forgive me for my ignorance with technical terminology and potentially dumb questions. I am trying to use the function lm() in R to determine ...
MEKS's user avatar
  • 1
2 votes
1 answer
74 views

How do we report a regression with categorical * continouns interaction?

I was wondering how would be the best way to report this model ? ...
Larissa Cury's user avatar
1 vote
0 answers
53 views

Is it possible to do linear regression on participants' level?

Each participant had 16 rating values, and there were two (say A and B) trial-wise parameters I could get based on our task. I want to see how A/B contribute to the rating for each subject. Is there ...
1011xx's user avatar
  • 11
3 votes
1 answer
177 views

How to calculate uncertainty in the sum of the predictions

I am using dummy data to ask my question: I have a linear model y~x. ...
yuliaUU's user avatar
  • 293
0 votes
2 answers
368 views

How to interpret a mediation analysis results

I am new in mediation analysis and I would like to know how to interpret the results obtained after performing a mediation analysis using R studio. The independent variable is gender (1 Men /2 Women, ...
Adrián P.L.'s user avatar
4 votes
1 answer
98 views

Three versions of the independent two sample t-test (and R)

This post concerns three versions of the independent two sample t-test: Student's t-test uses a pooled standard deviation in the denominator (all equations are shamelessly copied from Wikipedia - ...
stweb's user avatar
  • 378
2 votes
1 answer
106 views

Why is my lm() model unaltered by addition of a random effect?

I have a dataset with repeated measures (each plantID is tested at 4 different ppm of CO2 - image below). I have tried analyzing the data with and without a random effect of plantID: lm(CER ~ ppm, ...
Arielle's user avatar
  • 21
0 votes
0 answers
27 views

separate linear contrasts per condition

With this example data set ...
locus's user avatar
  • 1,181
0 votes
0 answers
182 views

How to model a data with heteroskedasticity in variance and outliers in R?

I have a dataset where variance is different across groups, and there exist some outliers too. I used robust linear regression lmrob() to handle outliers. However, ...
SteveMcManaman's user avatar

1
2 3 4 5
8