linear-regression

How to draw a barplot split by variable levels, while controlling for other variables via multiple regression?

家住魔仙堡 提交于 2021-02-11 12:58:24
问题 How can I draw a barplot for means, while controlling for other variables through regression -- in a split-bars-by-vars fashion? My general problem I conduct a research to figure out which fruit is more likable: mango, banana, or apple. To this end, I go ahead and sample 100 people at random. I ask them to rate, on a scale of 1-5, the degree of liking each of the fruits. I also collect some demographic information about them: gender, age, education level, and whether they are colorblind or

How to draw a barplot split by variable levels, while controlling for other variables via multiple regression?

送分小仙女□ 提交于 2021-02-11 12:57:08
问题 How can I draw a barplot for means, while controlling for other variables through regression -- in a split-bars-by-vars fashion? My general problem I conduct a research to figure out which fruit is more likable: mango, banana, or apple. To this end, I go ahead and sample 100 people at random. I ask them to rate, on a scale of 1-5, the degree of liking each of the fruits. I also collect some demographic information about them: gender, age, education level, and whether they are colorblind or

How to draw a barplot split by variable levels, while controlling for other variables via multiple regression?

北慕城南 提交于 2021-02-11 12:57:00
问题 How can I draw a barplot for means, while controlling for other variables through regression -- in a split-bars-by-vars fashion? My general problem I conduct a research to figure out which fruit is more likable: mango, banana, or apple. To this end, I go ahead and sample 100 people at random. I ask them to rate, on a scale of 1-5, the degree of liking each of the fruits. I also collect some demographic information about them: gender, age, education level, and whether they are colorblind or

R-squared within for a regression with multiple fixed effects [closed]

筅森魡賤 提交于 2021-02-11 06:30:32
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 10 months ago . Improve this question I would like to get the R-squared within for a fixed effect regression with multiple fixed effects (let's say Country, Year, Trimester). The least squared dummy variable (LSDV) model ( lm in R/ reg in Stata) would only provide the overall R-squared. The same is

plotting a fitted segmented linear model shows more break points than what is estimated

不问归期 提交于 2021-02-10 18:53:51
问题 I was helping a friend with segmented regressions today. We were trying to fit a piecewise regression with a breakpoints to see if it fits data better than a standard linear model. I stumbled across a problem I cannot understand. When fitting a piecewise regression with a single breakpoint with the data provided, it does indeed fit a single breakpoint. However, when you predict from the model it gives what looks like 2 breakpoints. When plotting the model using plot.segmented() this problem

plotting a fitted segmented linear model shows more break points than what is estimated

有些话、适合烂在心里 提交于 2021-02-10 18:51:20
问题 I was helping a friend with segmented regressions today. We were trying to fit a piecewise regression with a breakpoints to see if it fits data better than a standard linear model. I stumbled across a problem I cannot understand. When fitting a piecewise regression with a single breakpoint with the data provided, it does indeed fit a single breakpoint. However, when you predict from the model it gives what looks like 2 breakpoints. When plotting the model using plot.segmented() this problem

Linear regression with only previous values in moving window

百般思念 提交于 2021-02-10 06:49:49
问题 I have a huge dataset and would like to perform a rolling linear regression over a window of 60. However, I want that only the 60 previous values are considered for the linear regression. My Dataframe DF consists of following Columns: Date Company Y X1 X2 01.01.2015 Mill 0.13 -1 -3 01.02.2015 Mill 0.16 1 5 01.03.2015 Mill 0.83 3 4 01.04.2015 Mill -0.83 23 4 01.01.1988 Hall 0.23 1 3 01.02.1988 Hall 0.24 23 2 01.03.1988 Hall 0.78 19 -9 01.04.1988 Hall 0.73 4 12 01.05.1988 Hall 0.72 5 12 01.11

I keep getting the error :“ValueError: Expected 2D array, got 1D array instead:” for a linear regression process

蹲街弑〆低调 提交于 2021-02-10 06:29:32
问题 I have 2 arrays which are true_stress and true_strain. I want to do a linear regression to their log10 versions but I keep getting the said error. from sklearn.linear_model import LinearRegression log_tStress = np.log10(true_stress) log_tStrain = np.log10(true_strain) regressor = LinearRegression() regressor.fit(log_tStrain, log_tStress) predict = regressor.predict(log_tStrain) ValueError: Expected 2D array, got 1D array instead: 回答1: Well it kinda is just what it says.You are feeding a 1D

`ValueError: too many values to unpack (expected 4)` with `scipy.stats.linregress`

烈酒焚心 提交于 2021-02-08 13:47:15
问题 I know that this error message ( ValueError: too many values to unpack (expected 4) ) appears when more variables are set to values than a function returns. scipy.stats.linregress returns 5 values according to the scipy documentation (http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.linregress.html). Here is a short, reproducible example of a working call, and then a failed call, to linregress : What could account for difference and why is the second one poorly called? from

How can I modify these dplyr code for multiple linear regression by combination of all variables in R

坚强是说给别人听的谎言 提交于 2021-02-08 10:21:40
问题 lets say I have following data ind1 <- rnorm(99) ind2 <- rnorm(99) ind3 <- rnorm(99) ind4 <- rnorm(99) ind5 <- rnorm(99) dep <- rnorm(99, mean=ind1) group <- rep(c("A", "B", "C"), each=33) df <- data.frame(dep,group, ind1, ind2, ind3, ind4, ind5) the following code is calculating multiple linear regression between dependend variable and 2 independent variables by group which is exactly what I want to do. But I want to regress dep variable against all combination pair of independent variables