Skip to main content

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
1 vote
1 answer
50 views

Multiple comparisons and explanation of two-factor experiment

I am doing investigation with temperature and accession on trait of plants with R. Temperature: 25/20, 30/25, 35/30 Accession: V9,BTx623, 2-16-6, 1-10-4, 2-16-6, 19-22-12 The interaction and ...
Ken Hsu's user avatar
  • 123
0 votes
3 answers
60 views

What is a good starting model for fitting a rotated sigmoidal curve?

I'm trying to make a model to fit a rotated sigmoidal curve in R but don't know where to start when looking for an appropriate equation for the model. Some example data and the type of fit I'm getting ...
jaysmith's user avatar
0 votes
0 answers
29 views

Data with a limited window

I am working on my master thesis, but I am kind of stuck. I did a questionnaire about how much desire there is to have a certain product and what factors play the biggest role in their desirability, ...
sam gebruers's user avatar
0 votes
0 answers
28 views

Factorial anova results differ in R and SPSS

I am trying to run factorial anova in both SPSS and R but got different results. I convered the iv's into factors too. Any suggestions? ...
Ramakrishna S's user avatar
0 votes
0 answers
30 views

Interpreting results with a cox test

I am trying to compare 2 non nested models using coxtest from lmtest library. Lamentably I can not find some explanation about the results from this test. My first ...
Rodrigo Badilla's user avatar
1 vote
0 answers
23 views

Same p-value of overall model and binary predictor level 2 versus Intercept (lm function in R)

I have a response variable PC1 (it is PCA scores for a bunch of observations). I have a response variable category with two ...
Shakir's user avatar
  • 143
1 vote
0 answers
22 views

Understanding Contradictory Autocorrelation Findings in Residual Analysis

Question I came across an answer regarding how to evaluate the autocorrelation of residuals. However, when I apply two different approaches, the Durbin-Watson test (Fig. 1) and creating time-lagged ...
Pablo's user avatar
  • 33
0 votes
0 answers
31 views

Difference between a comparison of independent variables t.test and linear regression model of one category?

The thing is I am trying to obtain confidence intervals of several variables (food, blood chemical analysis...) of patients who are divided in two groups according the intervention. Until now I was ...
Javier Hernando's user avatar
0 votes
0 answers
13 views

R issue: lm() is printing NAs for rows once ncol > nrow [duplicate]

I'm running an lm() on lagged variables as part of a network analysis, and have the following dimensions: dim(final) [1] 197 277 dim(final_lag) [1] 197 831 The ...
user avatar
0 votes
0 answers
26 views

Why does removing the offset change the F-statistic of an anova model in R?

When a linear model with only a single categorical variables is defined without an offset, the F-statistic reported by summary() and ...
meta7's user avatar
  • 1
1 vote
0 answers
22 views

is it acceptable to do pairewise comparisons for mixed regressions that aren't independent?

I have a model specified as lmer(log(dv) ~ chosen*tasktype +(1|id)+(1|qs), data) The key issue in the data is that the groups are not indepedent, i.e., ...
Jinjin's user avatar
  • 111
2 votes
1 answer
76 views

Difference in coefficients between ar() and lm() using R?

When I use ar(method="ols") it should return the same as lm(), right? It doesn't: ...
PaulG's user avatar
  • 1,297
3 votes
1 answer
71 views

Best Practices for Difference-in-Difference Analysis of Quasi-Experimental Repeated Cross-Sectional (Cat.) Data Different Samples per Neighborhood

I'm working with repeated cross-sectional data where each measure comes from a different sample of respondents per neighborhood. My study aims to evaluate the impact of varying police patrol levels (...
DeMelkbroer's user avatar
0 votes
0 answers
19 views

Is a multicategorical multilevel mediation even possible?

I've tried to model a multicategorical multilevel mediation by using the logic of Hayes et al., 2014 on multicategorical mediation and an implementation of a multilevel mediation. Here's a MWE: ...
brizzen's user avatar
2 votes
0 answers
39 views

Fit from lm in R does not equal group means?

I define data such that: The outcome variable performance is a number between 0 and 1 ...
SimonSimon's user avatar
4 votes
1 answer
60 views

2x2 design (ANOVA): can i only look a 1 main effect and an interaction?

I have a model: ...
DS14's user avatar
  • 105
1 vote
0 answers
63 views

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

I am looking for a way to compare the results from two lmRob() functions statistically. Would that be a possible option for me: lmrob_female <- robust::lmRob(Y ~ X_binary + covariate1 + covariate2 +...
Emil's user avatar
  • 21
3 votes
1 answer
113 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
  • 206
0 votes
0 answers
23 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
  • 11
1 vote
1 answer
45 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
10 votes
2 answers
1k 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
18 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
15 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
48 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
520 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
57 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
3 votes
0 answers
188 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
  • 169
1 vote
2 answers
356 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
78 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
69 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
38 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
1 answer
71 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
17 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
  • 250
1 vote
0 answers
973 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
  • 391
2 votes
1 answer
54 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
  • 391
1 vote
1 answer
240 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
  • 14.5k
1 vote
0 answers
26 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
101 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
60 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
105 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
4 votes
1 answer
312 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
1 vote
1 answer
615 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
  • 11
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
40 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
442 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
  • 1,140
0 votes
0 answers
51 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
71 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
128 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
79 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
68 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

1
2 3 4 5
9